Questions tagged [python]

Python is a multi-paradigm, dynamically typed, multipurpose programming language, designed to be quick (to learn, to use, and to understand), and to enforce a clean and uniform syntax. Two similar but incompatible versions of Python are commonly in use, Python 2.7 and 3.x. For version-specific Python questions, add the [python-2.7] or [python-3.x] tag. When using a Python variant or library (e.g. Jython, PyPy, Pandas, Numpy), please include it in the tags.

Filter by
Sorted by
Tagged with
0
votes
0answers
2 views

is dataframe values is not a numeric a I want to change it as some number

column1 column2 column3 3 java 1 3 python 2 4 5 3 let say if column2 is not a numeric number in this case java and python is not a numeric so want to change ...
0
votes
0answers
3 views

Python Requests ConnectionErrorr [11001] getaddrinfo failed

OK so I'm working on this project for my intro to Python class and I can't seem to get around the error (tried every suggestion on the topic). I'm making a stock index webscraper using beautifulsoup ...
0
votes
0answers
6 views

I am working in terminal application(Python+MySQL)

def view_empdetails(): #this is my function: it works great conn = mysql.connector.connect(host="localhost",user="root",passwd="#####",database="#DB") cursor = conn.cursor() # this is ...
0
votes
0answers
12 views

Does WebAssembly run faster if written in C as opposed to Python?

There's a long list of languages that can be compiled into WASM. Is there any performance gain from writing in something like C or Rust over Python? Or is it all the same since it is being compiled to ...
0
votes
0answers
3 views

Problem with yolo compilation when attempting to use webcam

I installed the yolov3 darknet and it works fine. The problem comes when I try to use the demo for webcam. After changing the Makefila to OPENCV=1 and recompiling, I'm getting this output: ./src/...
-1
votes
0answers
4 views

Circle packing implementation

https://www.engineeringtoolbox.com/circles-within-rectangle-d_1905.html How I can implement the method by which he calculated the triangle packing in this site. There are 2 methods i need to ...
0
votes
1answer
8 views

pip3 install tensorflow-gpu installs tensorflow version 1.14.0

I am trying to install Tensorflow 2.0. These are the commands that I am running: $ pip3 install tensorflow-gpu When I open a Python Console (in Jetbrains PyCharm) import tensorflow as tf I'm ...
0
votes
0answers
6 views

Segmentation Fault in apache after changing environment from Python 2.7 to Python 3.6

I am trying to upgrade my python environment from 2.7.15+ to 3.6.9 on my debian server. After deploying the latest python 3 code and installing the requirements I noticed that apache started giving ...
1
vote
2answers
15 views

How to modify the value of numpy array based on another array?

I have a numpy array. I want to modify one array index by the chosen elements of another array. For example: import numpy as np t1 = np.ones((10,3)) t2 = np.arange(10) t1[np.where(t2>5)][:,2] = 10 ...
0
votes
0answers
8 views

Python bisection search confusion

I'm trying to work on the MIT intro to CS with Python problem set 1. Here's the problem (bottom of page 3): https://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-0001-...
0
votes
2answers
24 views

Items in list are also lists and I want to make them strings - Python

I have a function that takes in a list with values that are strings. It returns just the names of locations in the original list of words. The problem is somewhere in this function it makes each ...
0
votes
0answers
10 views

Uniform sampling within a range of values in a Pandas column?

I have some DataFrame of random floats: df = pd.DataFrame(np.random.uniform(0, 100, size=(10000, 1)), columns=list('A')) I'm specifically interested in the rows with values between 50 and 60: df[(...
0
votes
0answers
6 views

SQLAlchemy doesn't create table

I am just starting with SQLAlchemy for building a web application while reading Flask Tutorial. SQLAlchemy create_all() does not create tables. I have found this article, but models are written before ...
2
votes
4answers
31 views

Given an array of lengths, find closest combination to a total length

I have two sets of variables, a static array of segment lengths and a dynamic final total length to be specified by the user. For example, array lengths = [50,40,80,30,108,25], total = 150. How ...
0
votes
0answers
8 views

Beautiful soup complicated query question

I want to scarp the table on the following website https://www.hkab.org.hk/DisplayInterestSettlementRatesAction.do However, it has a very complicated query I tried the following code but I cant ...
0
votes
2answers
20 views

Adding comma makes python object as Tuple [duplicate]

Can you please explain one behavioral in Python. I have defined some server class class Server: ... Now when I crate object from it: s=Server("logiclic1","master","10.97.113.161", "00:50:56:80:6D:...
0
votes
0answers
17 views

how to execute command line step by step from python?

module called import subprocess First, I want to enter the folder path subprocess.run(["cd documents"]) Second, once I get access and enter to the folder then I want to display the file that ...
0
votes
0answers
8 views

Unsuccessful TensorSliceReader constructor

I am trying to make a chatbot using Python for a school project. I am basing mine off this video: https://www.youtube.com/watch?v=wypVcNIH6D4&list=PLzMcBGfZo4-ndH9FoC4YWHGXG5RZekt-Q . I ran into ...
0
votes
0answers
6 views

Discord.py Warning Command (help me) mass dm

A few days ago I was trying to create a warning command, a dm mass type, but instead of sending to all server users, send just a few people to a specific role. I was able to create just one mass dm ...
0
votes
1answer
19 views

multiplying and combining all elements in a list by all others but without duplication/repetition [duplicate]

we = [1,2,3,4] for i in we: for e in we: print('('+str(i)+' - '+str(e)+')') #del we[0] this is the result (1 - 1) (1 - 2) (1 - 3) (1 - 4) (2 - 1) (2 - 2) (2 - 3) (2 - 4) (3 - 1) (3 - ...
0
votes
0answers
9 views

Seating file in python that needs to be fixed

import sys, threading, time from PyQt5.QtGui import QPainter, QColor, QFont, QPen, QBrush from PyQt5.QtCore import Qt from PyQt5.QtWidgets import QWidget, QApplication, QPushButton, QDialog, ...
0
votes
1answer
19 views

is it possible to incorporate JavaScript or Python code into a previously existing VBA database? if so how? [closed]

So I'm working for a monastery at the moment and they've built their entire database in Excel and through that, Visual Basic. They want to know if it's possible to use JavaScript or Python to make ...
0
votes
1answer
15 views

Where does data not in a website's source code come from and how do I get it using BeautifulSoup? [duplicate]

I am trying to pull data from a local government's website using BeautifulSoup with Python, but the source code that it pulls down lacks the info I want. I know how to use BeautifulSoup and I can pull ...
0
votes
0answers
3 views

Element misalignment passing numpy array with distutils

I am using Anaconda Spyder 3.3.6 (Python 3.7) on CentOS 7. I have a 4D numpy array, surfaceVectors, where the 4th dimension is the unnormalized vector (size and direction) at each voxel of a 3D ...
0
votes
0answers
7 views

Creating an Image Mask in Python

I am trying to create an image mask that will accept an image and enable me to plot text to represent that image, similar to a wordcloud. I am currently collecting all of the x and y coordinates of ...
0
votes
0answers
18 views

computing from one sheet and appending that in next sheet using pandas

I have 2 excel sheets. I have constructed 2 data frames out of that. From one sheet, i do sum up based on one column. that is, In that sheet, more than one row of data for a specific site, where rows ...
0
votes
0answers
40 views

How to iterate list items to store as a dictionary and write it to json?

I have a list and I want to iterate and write it to write to json. For example: lis_1 = ['fellow','hello','yellow'] Now I store it as a dictionary: items_main = {} new_list = [] result_2 = {} items ...
1
vote
0answers
13 views

how to get my 2x2 subplots to be square in python

I need to make these 2x2 subplots square while still having them share the same axis and without changing the axis bounds. I really do not want to have to move my legend or change the range of my axis ...
0
votes
0answers
21 views

What's the best way to declare a list that updates itself inside a loop?

I am reading multiple CSV files and averaging them. Due to memory constraints, I can read only one at a time, so I have a routine for reading them on a loop that looks like this: first_iteration = ...
-1
votes
0answers
10 views

Question About Self.Head in Doubly Linked List

I'm learning about Doubly Linked List and got the following piece of code that can push item into doubly linked list and print items from the list class Node(): def __init__(self,data): ...
0
votes
0answers
8 views

How do I use FuncAnimation properly to animate a dot on a line graph?

import numpy as np import matplotlib.pyplot as plt import matplotlib.animation as animation TWOPI = 2*np.pi fig, ax = plt.subplots() t = np.arange(0.0, TWOPI, 0.001) s = np.sin(t) l = plt.plot(t, s)...
0
votes
0answers
8 views

python logging How to pre-process the message before being emitted by handler/formatter

python logging How to pre-process the message before emit by handler/formatter I want the handler/formatter to pre-process the message to log. logger = logging.getLogger('myLogger') logger....
1
vote
0answers
10 views

Unexpected, Intermittent execution with python3 list(set(arr))

I'm doing a few algorithm questions and ran into a strange issue in one of my test cases. The get_num_groups function returns an integer that the assert statements verify. The first assert statement ...
0
votes
0answers
15 views

Translate Python to LC3

I have an LC3 project. I have been working on it for days. Because I cannot figure it out, I created the required program in Python to try and help me in creating the LC3 code. Still struggling. (...
0
votes
1answer
18 views

Python Tkinter entry-point

So for a project on my school I am trying to make an GUI where I can add some info for some email so it will send it automatically through an python script. Now I do have a small problem. I made some ...
0
votes
0answers
22 views

How to copy what the printed version of a string would look like to a new string

Say that this is the repr version of my string raw = ''If the third-party evaluating agency is a NACES member\xa0and uses the CDGDC for their verification, you will not need to send a report from the ...
0
votes
0answers
10 views

Implement Downloader Class for downloading from Hadoop

How to Implement Downloader Class for downloading data from Hadoop datalake to the local machine
0
votes
2answers
21 views

Add a dictionary as a value to another dictionary with the same key

I have a dictionary like the following - parent_key : {child : 1, child :2} I have another dictionary with the same format - parent_key : {child : 3, child :2} Both have the same parent key and ...
-1
votes
0answers
18 views

Using Python. How do I add to my code a way for it to sum up the salary that the company has to pay depending on the day

The code is designed to help a company come up with the most economic form of hiring employees and having them get two days off each without leaving any days without any workers. I've tried all day to ...
0
votes
0answers
12 views

Verifying that an object instance complies with ABC in Python

I have an API that receives a serialized representation of an object that I expect to comply with a particular interface (known at development time). The serialized data I receive includes details ...
0
votes
1answer
14 views

Python 3.6 fails to open read-only file using “r+b” mode

In Python 3.6, when I attempt to "open('foobar', "r+b") with a file whose permissions are '-r--r--r--' (in CentOS7), I get a permission failure: "builtins.PermissionError: [Errno 13] Permission denied:...
2
votes
1answer
24 views

How to download a file using web URL in python? Download through browser works but not through python's requests

The file gets downloaded if the URL is entered in a browser (Firefox, Chrome, etc.). But when I tried to download the same file (using the same URL) with python's requests or urllib library, I don't ...
0
votes
0answers
11 views

Jupyter always crash after processing quarter of dataset

I am doing connected component of 3D point cloud data. My real data is about 8 mio rows with 3 column (XYZ). Since the large data, then I split the data into 32 part so each part consist only about ...
1
vote
2answers
22 views

groupby month-day hour using pandas

here is what my dataframe looks like: user_id time hour weekday location updated_at 2019-09-02 05:29:00 29279 5:29:35 5 0 ...
1
vote
1answer
40 views

How to close thread and start thread appropriate ways?

I need to run and close thread with input. Here, it uses input function to handle input. If input is start. then, run recv method as thread else input is close set second argument to False. False ...
1
vote
1answer
15 views

validate the data frame header with pandas regex

In pandas data frame has email header. for that i want to validate few domain names and special characters are available i have to save into new sheet as invalid sheet. Here is the example data frame ...
1
vote
1answer
20 views

typing.NamedTuple with a dictionary default

I'm trying to make a NamedTuple where one field defaults to an empty dictionary. This mostly works, however the default value is shared between instances of the NamedTuple: from typing import ...
1
vote
1answer
4 views

ValueError: matmul when trying to fit sklearn's linear regressor to pandas dataframe instanses

I've been trying to perform a simple multivariate linear regression on some dummy data using sklearn. I initially passed sklearn.linear_model.LinearRegression.fit numpy arrays and kept getting this ...
0
votes
1answer
18 views

Can not generate probability for Monte Carlo Simulation in python 3.x?

I have created a high-level Python random function for a Monte Carlo Simulation in python and my code is running correctly. However, I'm not able to generate a probability to draw: 2 - blue and 2 - ...
0
votes
1answer
9 views

replace any words in string that match an entry in list with a single tag (python)

I have a list of sentences (~100k sentences total) and a list of "infrequent words" (length ~20k). I would like to run through each sentence and replace any word that matches an entry in "...