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
8 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"...
0
votes
0answers
17 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 ...
0
votes
0answers
6 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
2answers
17 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
7 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
0answers
9 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
13 views

Python Performance Build From Source

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 from ...
1
vote
2answers
22 views

Python: List Index Out of Range / Append List

Here is my list sample: Address list Here is my problem: List index out of range (1) 'int' object is not iterable (2) Explanation: My Address list has no nulls and I tried appending empty '...
3
votes
1answer
20 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
11 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 ...
3
votes
1answer
18 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
10 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
19 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
2answers
30 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
11 views

How to fix ERROR: Python requirements are missing

Im trying to make a xcode project that is python using kivy and when i go to build kivy in terminal it says ERROR: Python requirements are missing To install: pip install -r requirements.txt I tried ...
0
votes
0answers
13 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
10 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
14 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
27 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
15 views

Error on shuffle deck of card using Python

I am trying to write a program that: 1. a function that creates a deck of cards 2. a function that randomly changes the order of cards in the deck. 3. a function that removes the first card_count ...
0
votes
2answers
17 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
10 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
12 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
33 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() ...
0
votes
0answers
15 views

How can I cancel an active boto3 s3 file_download?

I'm using boto3 to download files from an s3 bucket & I need to support canceling an active file transfer in my client UI - but I can't find it. There is a progress callback that I can use for ...
0
votes
2answers
20 views

Unable to Access Other Apps in Django

I am writing a beginner Django app. I am currently able to the first app that I created. However, I am not able to figure out how to access the other two apps. swiss (project) |_ app_picker (...
0
votes
0answers
9 views

How to access django models from a scheduled script?

TL;DR: I have an app that I want to run a routine every day at midnight (for that I'm using APScheduler). In the middle of this routine it's supposed to access data from a few django models. The ...
-4
votes
1answer
16 views

What does these Pandas code says ?, pls explain it to in normal term?

I wanna understand this code in a feature engineering term train['TransactionAmt_to_mean_card1'] = train['TransactionAmt'] / train.groupby(['card1'])['TransactionAmt'].transform('mean')
0
votes
1answer
22 views

How do I display the articles in 2 or 3 rows in a page?

I've been making the blog with python,flask,sqlalchemy,html. And now I can display the articles in the page. But I'm only able to display it in 1 row like below one with the codes below.By the way,...
0
votes
0answers
10 views

is it possible to use Format String Syntax in pandas DataFrame?

this code is to plot a table like a joint probability mass function. data = np.arange(6).reshape(2,3) summation = np.sum(data) arr2 = np.empty((2,3), dtype='U30') for i in range(len(data)): for j ...
1
vote
1answer
20 views

Dataframe slicing from nearest value that is not date

I have a simple dataframe as follow df = pd.DataFrame({"A": [10,10,20,20,30], "B": [40,40,50,50,60]}) I am wondering if i want to get return rows which value is the nearest to the given value. For ...
0
votes
0answers
11 views

“Unexpected indent” exception occurs whlie compiling MMDetection

I'm installing the environment of Defromable Convnets form: https://github.com/open-mmlab/mmdetection Following the instructions here: https://github.com/open-mmlab/mmdetection/blob/master/docs/...
0
votes
0answers
19 views

Python: filter the datetime year to the data without displaying the datetime

Currently, I have created a dictionary, that stores my data from a csv/excel file . I am trying to output that those that is under year 2015. Currently my codes are extracting all the datetime in ...
0
votes
1answer
14 views

how to fix 'size', 'occurred at index City' error

I am trying to do the example in Use Python & Pandas to replace NaN in the 'size' column with a specific value, depending on the City. In the example below i am trying to assign a value of 18 if ...
-3
votes
1answer
22 views

Chatroom application

I was wondering how I can create a local chatroom using a website / app that connects to a server which will only allow the users that are connected to the router(LAN) to be able to chat.
1
vote
0answers
14 views

Fixing a meeting room function schedule with double and triple bookings to determine space usage

I need to calculate the total amount of time each group uses a meeting space. But the data set has double and triple booking, so I think I need to fix the data first. Disclosure: My coding experience ...