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, use the [python-2.7] or [python-3.x] tags. When using a Python variant or library (i.e Jython, Pypy, Pandas, Numpy), please include it in the tags.

0
votes
0answers
4 views

What does the star * has to do with the glob in python?

I am new to python and I am using for scripting. I am trying to understand how glob works and what is the star * related to it and how it works? There are so many resources but none of them shows ...
0
votes
0answers
7 views

How to fix Python code returning TypeError: 'str' object is not callable?

i've been trying to send a POST HTTP request using Python (first time using it) and it keeps returning a TypeError: 'str' object is not callable My code: import requests import json c100 = "100"; ...
0
votes
0answers
6 views

Is there an optimal way to find the minimum distance from an ellipse to a point without traversing every point in Python

I need an algorithm that requires the minimum distance between a conic section's perimeter and a point. So far, I've tried navigating the conic for if the orthogonal vector from the perimeter passed ...
0
votes
0answers
11 views

Replace values with conditional match in another dataframe Python 3

I have 2 pandas data frames as below. What I need is to replace the text in cols B, C, D in df1 with the values from df2['SC'], conditional on df2['Title'] column. df1 A B C D Dave ...
1
vote
0answers
12 views

if condition in rows and columns recursive

Issue in applying if conditions in Rows and columns of 2 different dataframes. df1 X1 X2 X3 X4 X5 10 12 8 4 6 df2 class MARKS class_1 8 class_2 6 class_3 9 class_4 ...
0
votes
0answers
6 views

Extracting arc parameters from a DXF using EZDXF Python

I am trying to extract the Arc Parameters from a DXF using Ezdxf. So far I have been able to extract the center, start_angle, end_angle and radius. Is there a way, I can find out the direction of ...
1
vote
1answer
17 views

Indent in Python makes Variable inaccessible

So I have the selfmade class "element" and I want to create a function, that takes in keyword-arguments which get passed into the constructor of "element" It looks like this: class element: ...
0
votes
0answers
4 views

vtk reader doesn't read all the data arrays from a binary .vtk file

I want to upload the content of a binary .vtk file into python. My python vtk wrapper is installed with conda and the version is 8.2.0. Although I know that the file should contain at least 11 scalar ...
0
votes
0answers
6 views

Dynamically generating dataframes from another dataframe

I need help generating a dynamic list of files to be opened by pandas.read_csv() _ExtensionToLookFor = '.csv' # Setting up boolean to check for CSV _isCsv = None # Returning all files in folder ** If ...
0
votes
0answers
7 views

Properly reading in a CSV file in pandas with double quotes

I have a csv file, where each line is enclosed with double quotes, where the first field is not enclosed in double quotes, but all other fields are, like this - "Col1,""Col2"",""Col3"",""Col4"",""...
0
votes
2answers
11 views

How to assign unique values to groups of rows in a pandas dataframe based on a condition?

My dataframe looks like this: import pandas as pd example = [{'A':3}, {'A':5}, {'A':0}, {'A':2}, {'A':6}, {'A':9}, {'A':0}, {'A':3}, {'A':4}] df = pd.DataFrame(example) print(df) Output: df 3 5 0 2 ...
0
votes
0answers
6 views

train_test_split giving me different result

i'm using a conv net (CNN) to classify image. I also want to extract feature from a fully connected layer and apply an SVC I do a train/validation/test split for CNN and only train/test for SVC since ...
-1
votes
0answers
3 views

How to make word cloud for each cluster in kmeans

"I trying to print data points in each cluster using word cloud and my data points is vectorizer data(BOW),How to print words in each cluster using word cloud..?" I already done optimal k for k-means ...
0
votes
0answers
6 views

How can I make a Gnuplot graph with the output of a python script and view it through Apache webserver?

I made a python script which will measure the temperature and humidity of the room and I want to make a graph with Gnuplot which shows the output of it on a webpage with Apache. I already have what I ...
0
votes
0answers
7 views

Authlib SSLError with self signed certs

I'm using authlib with the following code: session = OAuth2Session(client_id, client_secret) token = session.fetch_access_token( access_token_url, client_id='.....', method='POST', ...
0
votes
0answers
3 views

Create new Individuals on Mate function Using Deap Framework

I am trying to create a personalized mate function. In such a way that creates a new Individual from two Individuals present on the population. Here's my mate function: def BREED(parent1, parent2)...
0
votes
0answers
3 views

VI_ERROR_TMO (-1073807339): Timeout expired before operation completed

I try to connect my Power Analyser Rohde&Schwarz, HMC8015 ('ASRL3::INSTR') to my computer, and to read any data that my device can show with python VISA. I have a lot of problems with the code ...
0
votes
1answer
11 views

Confusion about neural networks activation functions

I followed a tutorial about an image classifier using Python and Tensorflow. I'm now trying to apply deep learning to a custom situation. I made a simulation program of sellers/buyers where the ...
0
votes
0answers
6 views

How do I create a log(x) graph using xlsxwriter in python?

I am trying to create a log(x) graph in xksxwriter, I am using " chart1.set_x_axis({'log_base' : 10})" to set the x axis as a logarithmic axis. However the graph still appears linear on both ...
0
votes
1answer
16 views

(pandas)How can I create a unique identifier based on three similar columns of data, where order doesn't matter?

(Python/Pandas) I'm doing some analysis on UK House Price data looking at whether house prices respond to quality of nearby schools. I have matched the URN (Unique Reference Number) of the three ...
-1
votes
0answers
10 views

I need to load a txt file into Python and delete data sets considered as errors determined by certain conditions, and i dont know what to do

Im trying to load data from a txt file in Python and remove errors from it. The objective is to load a txt file, convert it to a matrix, and then remove errors from the matrix. You can see what i am ...
2
votes
0answers
11 views

Scraping attributes from drop down sub menu

I am attempting to scrape specific Data from a website. The data exists only in drop down sub menu of another drop down, and gets generated only after selecting specific option of main drop down menu. ...
2
votes
1answer
12 views

Pandas merge_asof does not want to merge on pd.Timedelta giving error “must be compat with type int64”

I am trying to merge the following files df1 unix_time,hk1,hk2,val2,hint 1560752700,10,15,3,6:25am 1560753900,20,25,5,6:45am 1560756600,10,10,-1,7:30am df2 unix_time,hk1,hk2,val,hint 1560751200,...
0
votes
0answers
16 views

I want to write a 75000x10000 matrix with float values effectively into a database

thanks for hearing me out. I have a dataset that is a matrix of shape 75000x10000 filled with float values. Think of it like heatmap/correlation matrix. I want to store this in a SQLite database (...
0
votes
0answers
6 views

How can i get the name of a window with pywinauto

I'm using pywinauto to automate some process. I've already used it for other app and it works perfectly but I wan't, this time, to use it for Vysor.exe (screen sharing application with phone). The ...
0
votes
0answers
4 views

How do I read files with a01 extension

I have read a lot about opening up files with .axx extension, but I had no success. Fox Pro, renaming gave garbled result, hence I came here. My requirement - I need to read database tables inside ...
0
votes
0answers
8 views

Plotting of Graph with the each data point

# 3 = rest cycle # 1 = discharge rest_start = np.zeros(len(mode)) past_mode = float(3) for i in range(len(mode)): if mode[i] == float(3): if mode[i] != past_mode: rest_start[...
0
votes
1answer
18 views

Use of isinstance(variable,data_type_name) function for NoneType data type gone wrong [duplicate]

Suppose a variable is defined: a=None On running below code: print(isinstance(a,NoneType)) gave error: NameError: name 'NoneType' is not defined For any other data type, its working correctly ...
0
votes
0answers
8 views

How to convert a list to a dataframe with 1 row [duplicate]

row = ['Gr', 'http://www.purriodictableofcats.com/images/b-grumpycat.jpg', 'Female', 'Real Name: Tardar Sauce', 'Hit the internet: 2012', "Interesting Facts: Being both grumpy and adorableNamed ...
0
votes
1answer
9 views

How to execute the *sudo* command on remote server using python paramiko package?

I treied to execute the sudo command from the remote sertver but it is giving an error [u'sudo: no tty present and no askpass program specified\n']
0
votes
0answers
37 views

How do I create a function that will return a value in a dictionary for each row within a data sheet using Python?

I need to create a new column in my table for a state region that populates a region for every row of data (each having a state). How do I write a function to call upon a dictionary for each row item? ...
0
votes
0answers
10 views

Is it possible to reflect a table in MSSQL server to SQLITE using sqlalchemy?

I'm trying to make a local copy of some tables from a read-only MSSQL server database in SQLite. I'm using sqlalchemy to do this, however, I don't seem to find a solution. Here is what I tried so far:...
8
votes
1answer
65 views

Why are True and False being set in globals by this code?

I was recently reading some code online, and saw this block: if 'True' not in globals(): globals()['True'] = not None globals()['False'] = not True What is happening here? Why would True ...
2
votes
0answers
17 views

How to add python docstring for nested dictionary return type

I'm trying to create a docstring for a return type Dictionary. The dictionary has Date->Dictionary key-value pairs. The nested Dictionary has 2 string->int key-value pairs and a string->Dictionary key-...
4
votes
2answers
23 views

Pandas Timestamp rounds 30 seconds inconsistently

I'm trying to round a pandas DatetimeIndex (or Timestamp) to the nearest minute, but I'm having a problem with Timestamps of 30 seconds - some rounding up, some rounding down (this seems to alternate)....
0
votes
1answer
10 views

I want to plot AUC wrt to depth of decision tree but with min_samples_split value changing

I want to plot the train auc and cv auc w.r.t depth change in decision tree model but min_samples_split value changing as shown in the code . If i fix the value of min_samples_split = 5 or 10 . then ...
0
votes
1answer
11 views

How can I do it assertion on plain text in Python?

I have plain HTML text <b>text</b> on the webpage. With Selenium webdriver, I need to make it easy to check that the text is on the webpage. I can find an element using xpath, but I don't ...
-1
votes
0answers
7 views

This is a verification code identification process.Why doesn't the last few lines of the codes about recognizing the single character work?

for i in range(cuttingImgNum): # 对于每个字符 try: file2 = './output/%s-cutting-%s.jpg' % (imgName[0], i) str_img = str_img + pytesseract.image_to_string(Image.open(file2), ...
0
votes
0answers
33 views

How to convert this string “123,000” to float “123.000” in Python? [duplicate]

I am trying to read data from a website that the response is like 123,000 and I should convert it to 123.000 to plot it. Is there any function for this?
0
votes
0answers
22 views

Retrieve many live stock quotes to one CSV file using Python

This code correctly prints all four live stock quotes from Interactive Brokers using ib_insync. Stock is an imported function within ib_insync. stocks = ['SPY','ANGL','GDX','TMV'] test = list() for ...
1
vote
1answer
21 views

Which dtype would be correct to prevent numpy.arange() from getting the wrong length?

I am trying to get a shifting array containing 200 values in a range with a difference of 40. Therefore i am using numpy.arange(a, b, 0.2) with starting values a=0 and b=40 and going upwards (a=0.2 b=...
0
votes
0answers
8 views

How to gather and sort logging output from multithread processes

I have a CLI tool written in Python that operates on a bunch of files and makes use of multithreading for small file operations. While the parts executed as threads are only subsections in a longer ...
0
votes
1answer
25 views

Unable to concatenate dataframes correctly

dfs is: StockCode 84077K 32.694876 23005J 28.248135 85099BJ 24.581063 23084M 24.078340 85099FC 19.276526 Name: 127269, dtype: float64 where 127269 is the CustomerID dfc is: ...
2
votes
2answers
42 views

How to write list of list in chunk file

I have list of list that looks like this: listThing = [['apple','mango','cherry], ['dog','cat','bird'], ['rose','jasmine','sunflower'] ['hospital','house','...
0
votes
0answers
9 views

Receiving “Invalid load key, 'v'.” when trying to run truecase in Python

I'm trying to run a short snippet of code that uses the truecase Python package (it's used to restore capitalization in text), and I'm receiving an UnpicklingError because it loads a tokenizer from ...
-2
votes
0answers
20 views

Why am i getting type error builtin function? [on hold]

I want the index number of an element contained in the list using the index function. Student.insert(5,'Rajat') Student ['Ashis', 'Tiya', 'Ishan', 'Rajat', 'Rajat'] Student.index['Rajat'] Expected ...
0
votes
0answers
11 views

What do I measure with pyAudio?

I am recording sound using the python pyAudio library, and plotting it with matplotlib. Here I'm recording the volume and want to know in which value it is and how many Dezibel this are. Currently I ...
-1
votes
2answers
14 views

How run bottle application as docker-container?

I make bottle-framework-application, it works fine on localhost. I use virtualenv. Then i build docker container. My Dockerfile: FROM ubuntu COPY . . RUN /bin/bash -c "source venv/bin/activate" ...
0
votes
1answer
10 views

why doesn't list_companies() return the companies I created in Google cloud Talent Solution?

I have: from google.cloud import talent_v4beta1 CLIENT = talent_v4beta1.CompanyServiceClient() PROJECT_ID = '...' PROJECT_PATH = 'projects/{}'.format(PROJECT_ID) company = { 'display_name' : ...,...
0
votes
2answers
13 views

Can I tell Django to run some function after a file is uploaded through admin panel?

I have models like this: class NameReplacements(models.Model): excel_file = models.FileField(upload_to='excel_files') class NameReplacement(models.Model): name_to_replace = models.CharField(...