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
3 views

Pandas - including column name as argument in function with string split() Method

I'd like to include the column name as an acceptable argument for this function to make it more flexible. def func(DataFrame, column): DataFrame.column.str.split('', n = 5, expand=True) As ...
0
votes
0answers
8 views

Append Series to Dataframe columns

I am trying to add the generated values of Date, Quantity, Price inside the variable el, I get the Type error,I even tried concat, every time the values generated are stored in s el = [Trade(pd....
0
votes
0answers
6 views

How do you get Visual Studio Code to use different Python interpreter?

I'm new to VS Code/Python, and I'm trying to get VSCode to run a specific version of Python (seems I have multiple versions installed). I tried the following code: import sys print(sys.version) ...
0
votes
0answers
23 views

Given a list, output a new list who''s length is 1 less than the original one

Working with a question right now where it asks me to generate a new list from a given list who's length will be 1 less than that of the originals. I think I know what concepts need to be used but I ...
0
votes
0answers
7 views

how to read tfrecord file

i have pieces of codes that writes a tfrecord file like this filename = "D:\\nvdata_.wav" recname = 'list.tfrecord' f_wav = wave.open(filename, 'rb') num_frames = f_wav.getnframes() print(num_frames) ...
-1
votes
0answers
11 views

C struct encoded binary data file read in python

This code reads binary file. Read data is converted into signed values and gets plotted if the user wants it. Binary file has below struct data encoded consecutively till the end. struct ...
0
votes
0answers
5 views

Tkinter Widget Issue

I am trying to build a widget for my virtual assistant project. When I run my code, all I am getting is a blank widget with black background. The background color that I have set, The components that ...
0
votes
0answers
4 views

How to I populate data from a Json text file into a tkinter treeview ? PYTHON

How do I populate a tkinter treeview from a json text file ? Below is my json txt file that I wish to populate it into a tkinter treeview. Any help for me to get started is much appreciated, as I have ...
0
votes
1answer
15 views

How to generate random numbers with positive z axis?

I want to generate the 3-Dimensional random numbers, but with the condition that z-component of the array should be positive, x and y can be positive and negative. I can generate both positive and ...
1
vote
0answers
10 views

How to get spinbox to display list in text field? - Tkinter

I am trying to make a news aggregator GUI that displays the headlines and publication dates from a saved news rss feed HTML file. I want the GUI to display 'X' news headlines and publication dates if ...
1
vote
0answers
7 views

PermissionError: [Errno 13] Permission denied: 'emails2/Train'

I've scouted around on stackoverflow and different websites but I seem to have not found a solution still. My issue is that I'm trying to access two different folders which contain "ham" or "spam" ...
-1
votes
0answers
9 views

How can I synchronise data from two tables recorded at different time steps using python?

I have two tables. Table1 has data recorded at 10-sec intervals and the data in Table2 was recorded at 1 or 2-sec intervals. I want to synchronize these two tables in a way that the whole data from ...
0
votes
0answers
16 views

Print specific words from .json on python

I am using twitter and downloaded a sample code from:" https://stream.twitter.com/1.1/statuses/sample.json" I used pretty printing but it doesn't print like how I want it. I only need the user "name"...
-3
votes
1answer
38 views

Please help achieve below result with Python

enter image description hereJson 1: Key Value identifier 1111 Y 1 2222 N 1 3333 Y 2 4444 N 1 JSON2: ID name address zip ...
1
vote
1answer
14 views

copy and paste each column from an existing csv file into a new csv file

So I have an existing csv file with multiple columns. I am trying to copy each column (one by one) and paste it into a new csv file. The name of the new csv file will be the header of the column. I ...
0
votes
3answers
34 views

Python strings, lists and process string in for loop

i am forcing myself to properly learn python, instead of just hacking on it when i want something. going thru a book, and i want to process in a for loop, thats working with a list: magicians = ['...
0
votes
0answers
8 views

Do I need to use “bigMod algorithm” in python?

As python don't have any limitation in storing numbers like c or c++, do I need to apply the bigMod algorithm? My this bit of code can handle the situation pretty smoothly. number1 = ...
0
votes
0answers
10 views

How to paginate list of dictionaries that comes from elasticsearch query using flask paginate?

I am having difficulty using pagination. I have to paginate elasticsearch query but when i was hitting second page it was showing blank because it's sending Get request and again elasticsearch query ...
0
votes
1answer
13 views

Reassigning dataframe rows or variables with iloc returns NaN

I have a "dataframe A" that is partially complete; some rows are missing data. The missing data can be found on rows in another "dataframe B" (with the same labels, but not position). When I try to ...
0
votes
0answers
20 views

Python Performance Build From Source

I need to build a performance (non-debug) version of Python, from source obtained from www.python.org/ftp/python. On a freshly installed Ubuntu 18.04 LTS server, obtained the source for Python3.8 ...
1
vote
3answers
35 views

Python: List Index Out of Range / Append List

Here is my list sample (data): Address list Here is the snippet of the list: ['PO Box 4653, Stockton, California, 95204', '157 Adams St., Stockton, California, 95204', ... Here is my problem: List ...
3
votes
1answer
26 views

How to subset pandas dataframe columns with idxmax output?

I have a pandas dataframe: import numpy as np import pandas as pd df = pd.DataFrame(np.random.randint(0,40,size=(10,4)), columns=range(4), index = range(10)) df.head() 0 1 2 3 0 27 10 ...
0
votes
0answers
15 views

write a program to read data from a file “marks.dat” which stores marks of 10 students in format “rno,name,marks”.for ex:12,hazel,68

Please tell me how can I take input in given format from the file and then calculate their average. First of all I made a file named "marks.dat" in text format and then in my python I opened the file ...
4
votes
1answer
25 views

Pythonic way to replace specific values with other values of numpy array within particular indices

I have seen answers for each part of my question. For example np.where(arr, b, c) converts all b's in arr to c. Or arr[arr == b] = c does the same. However, I have 1000 labels in a numpy array, ...
0
votes
1answer
12 views

is there way to convert daily predictions to hourly predictions in pandas

#df_test.head(3) ID Datetime 0 18288 26-09-2014 00:00 1 18289 26-09-2014 01:00 2 18290 26-09-2014 02:00 #df_test['Datetime'] = pd.to_datetime(df_test['Datetime']) #df_test = ...
0
votes
0answers
9 views

(sqlite3.InterfaceError) Error binding parameter 4 - probably unsupported type

I'm not sure which part of the code is giving me the interface error. Any help is appreciated. This is what is being inserted that's not being passed through correctly: [SQL: INSERT INTO minutes (...
1
vote
1answer
25 views

Django Images In Media Not Displaying Despite Correct Settings

I'm trying to upload an image from a form and display it on another template, however the images in media cannot be found. Model class Upload(models.Model): image = models.ImageField(upload_to='...
0
votes
3answers
48 views

Why use Java/Kotlin instead Python on Android?

I'm novice. That's why I can't understand the essential difference between using Java/Kotlin or using Python with its numerous modules for Android application development. Is there a good reason that ...
0
votes
0answers
12 views

How to fix ERROR: Python requirements are missing

I’m trying to make an Xcode project that is python using kivy. When I go to build kivy in terminal it says: ERROR: Python requirements are missing To install: pip install -r requirements.txt I ...
0
votes
0answers
17 views

pandas dataframe custom imputation with nearest values

I have this dataframe df = pd.DataFrame({"A": [10, 10, 10, 22, 30, 30, 30, 30, 30], "B": ["a", "a", "b", "b", "b", "a", "b", "b", "b"], "C": [2, 5, 10, np.nan, 15, 20, 35, 35, 35]}) so my dataframe ...
0
votes
1answer
22 views

How do I find the midpoint of two numbers that are represented as a string and partial fraction eg. '1 1/2 - 2'?

l = ['1 1/2 - 2', '1 - 1 1/2', '1 1/4 - 2', '1 1/4 - 2', '1 - 11/2', '3 - 5', '1 1/4 - 2'] How do I find the midpoint for each of ranges in the list? For example the first one '1 1/2 - 2' should be 1....
-2
votes
2answers
22 views

The Python IDE is saying that my “computer_score + 1” and “user_score + 1” has no effect, any idea why?

Win conditions can't be met because the computer_score and user_score aren't be added to like intended. It also won't register the first few user_plays at random. It's like it decides when to store ...
2
votes
1answer
15 views

Discord bot is not finding channel by name

I am making a Discord bot and when it boots up I am having it search through the guilds text-channels and checking for a specific channel name. If I print out the list of channels, it finds all of ...
0
votes
1answer
14 views

Possible to add a bidirectional LSTM after a 2D CNN in Keras?

I am using 2D CNN with input shape (20,20,1). Can I add LSTM layer after 2D CNN layer? nb_classes = 2 nb_kernels = 3 nb_pools = 2 def cnn_model(): model = Sequential() model.add(ZeroPadding2D((1, 1),...
0
votes
0answers
17 views

Is there a way to embed file ask directory in a tkinter frame?

I am new to tkinter and would like to know if there is a way to embed a directory listing to a frame in my GUI. The purpose of embedding is to automatically display all the images in the folder on to ...
1
vote
2answers
30 views

How to split the column with deleieter

I have a csv. need to split the \n with , name,address 711-2880,Mankato\n96522\n(257) 563-7401 971-2880,CA\n965\n(01) 563-7401\nNebraska My COde is below import pandas as pd df = pd.read_csv('test....
0
votes
1answer
20 views

TypeError about number of arguments shuffling deck of cards

I am trying to write a program that: a function that creates a deck of cards a function that randomly changes the order of cards in the deck. a function that removes the first card_count cards from ...
0
votes
2answers
18 views

beautifulSoup soup.select() returning empty for css selector

I am trying to parse some links from this site https://news.ycombinator.com/ I want to select a specific table document.querySelector("#hnmain > tbody > tr:nth-child(3) > td > table") ...
-1
votes
0answers
12 views

SQLAlchemy how do I disable concurrent sessions?

config.py import os basedir = os.path.abspath(os.path.dirname(__file__)) class Config(object): SQLALCHEMY_DATABASE_URI = 'mysql+pymysql://root:[email protected]/mydb' UserModel.py from flask ...
0
votes
0answers
6 views

module 'tensorflow.python.framework.ops' has no attribute 'to_raw_op'

module 'tensorflow.python.framework.ops' has no attribute 'to_raw_op' from future import absolute_import, division, print_function, unicode_literals, unicode_literals import os import tensorflow as ...
-3
votes
0answers
13 views

How can I validate the mobile numbers which are telegram users from a list of numbers?

I am having several excel file which contains the mobile numbers, I want to filter the only numbers which are telegram users? I tried using a telegram bot but it only gives chat id when the user uses ...
0
votes
0answers
7 views

Issues installing Psychopy, failed to build pyWinHook wheel

Sorry if this sounds like a basic question. I'm a cognitive scientist trying to learn Python. I've been trying to install Psychopy module on pycharm for 3 days and I can't get it to work. Whenever I ...
0
votes
1answer
7 views

How to get avatar url of the person who sent the message?

How do you get the avatar url of the person who sent the command from the context? @client.command() async def test(ctx): print("Username is = " + ctx.message.author) print(ctx.message.author ...
0
votes
0answers
10 views

Mongodb aggregation pivot an embedded list

I have a document structure with an embedded list that after I have used an aggregation pipeline to unwind, I end up with the following. Note: I am using Python with pymongo for this query. ...
0
votes
0answers
8 views

Change top-left logo of pyqtgraph application [duplicate]

I am currently working with pyqtgraph and want to change the top left image to a custom logo.
0
votes
0answers
8 views

Subscribing to eye gaze data Tobii Research

I am using an Alienware 17 R5 laptop with the Tobii eye tracker built in. I am trying to access any data from built in eye-tracking system. The code that I am using is essentially the same demo code ...
0
votes
1answer
20 views

why does numpy int16 give 26 bytes memory space?

I want a fixed size (2 byte/16 bit) integer for further processing. But sys.getsizeof()prints a size of 26, I don't have anything larger or smaller than the max and min int16 can hold. Why is that, ...
3
votes
4answers
35 views

Get value_counts() for list of tuples

I'm very familiar with how to return value_counts from a pd.Series. However, how would I get the value counts from a list of tuples in a dictionary? Say that I have the following tuples in dictionary ...
0
votes
0answers
7 views

How to compile a kivy project with other libraries?

I just make a python file with kivy, cv2 and webcolors. Watch this! from kivy.uix.widget import Widget from kivy.uix.boxlayout import BoxLayout from kivy.uix.gridlayout import GridLayout from kivy....
2
votes
1answer
15 views

Which coroutine is sequential?

I'm studying the HBMQTT docs at hbmqtt and there are 2 functions which do the same thing, basically to publish 3 messages to an MQTT broker: @asyncio.coroutine def test_coro(): C = MQTTClient() ...