Episode #125 of the Stack Overflow podcast is here. We talk Tilde Club and mechanical keyboards. Listen now

Questions tagged [python-3.x]

For questions about Python programming that are specific to version 3+ of the language. Use the more generic [python] tag if your question is not version-specific. Use the [python-2.x] tags for Python 2 questions.

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

Why the python enviroment isn't provided by pyenv。

I use pyenv manage my python versions. But I found when i install package by pip, The errors below: File "/usr/local/lib/python3.7/site-packages/setuptools/__init__.py", line 145, in setup ...
0
votes
0answers
12 views

Python Format Specs examples

I'm trying to understand using the python Format Specs for formatting some values. It says that the format of format is: format(value[, format_spec]) And an example of this to format a number could ...
-1
votes
3answers
24 views

Why Join Function isn't working when I converted my list to string

I expected the output to be 123 using Join function but am not getting the desired result f=['1','2','3'] p=str(f) k=''.join(p) print(k) output: ['1', '2', '3']
-2
votes
2answers
22 views

how to take an input and put it in a list in a dictionary

How do I take an input and append it as a list in a dictionary. So far I've tried: fruits = {} add_fruit = dict((input('Enter fruit follow by prices:').split(','' ') for i in range(x))) fruits....
-1
votes
1answer
19 views

Is it possible to create two ranges for a randint in Python?

I'm fairly new to Python and am trying to find a way to generate two separate, random numbers. I'm using a randint with a range of 0 - 100: (randint(0, 100)) Is there any way possible for a newbie ...
0
votes
0answers
6 views

AH01630: client denied by server configuration: /djangoDeployments

I am deploying a django application but I am having problems with the apache2 configuration. It gives me the error: AH01630: client denied by server configuration: /djangoDeployments I already ...
0
votes
0answers
17 views

increment column value by 1 based on the previous row

I have a pandas dataframe like below: data=[['A',1,30], ['A',1,2], ['A',0,4], ['A',1,4], ['B',0,5], ['B',1,1], ['B',0,5], ['B',1,8]] df = pd.DataFrame(data,...
1
vote
0answers
14 views

How to optimize percentage check and cols drop in large pyspark dataframe?

I have a sample pandas dataframe like as shown below. But my real data is 40 million rows and 5200 columns df = pd.DataFrame({ 'subject_id':[1,1,1,1,2,2,2,2,3,3,4,4,4,4,4], 'readings' : ['READ_1','...
0
votes
1answer
13 views

How do I make a list of Names, Times and Positions of racers participating in a race with python?

Basically, I have to create a list of Participants for 4 groups (I would like to sort the groups), record their times and their rank in the race and produce a neatly formatted table of results. I ...
0
votes
0answers
4 views

How to create network graph tree with weights using python matplotlib/seaborn

I have data like Each transactionid has 33 columns(test cases) each testcase result has one of the result among [PASS,FAIL,SKIPPED,NA]. Now I want to create weighted graph tree to show the ...
1
vote
1answer
25 views

Call a method in a class many times and the variable stays consistent

Writing a hangman program for Python and want a variable (self.masked_word) to stay consistent as I call the method many times... For instance if the secret word is 'hello' and I play: game.guess('...
0
votes
0answers
12 views

SendMessage winapi Python

I think it's easy, i found some winapi example but i don't understand how they work. I want send a message on a "process", like 'notepad.exe' how can i? Ex: i press number '1' script send & write ...
0
votes
1answer
18 views

Pandas: Import multiple CSV files and append together so that the elements line up according to the time index

I have several hundred CSV files that come from different sensor data points. They measure energy flow hourly. They were installed at staggered times throughout the year, so each data file begins on a ...
0
votes
0answers
36 views

ValueError: invalid literal for float()

I am trying to read lightware rangefinder SF11 through serial but using Raspberry, and I am not familiar with Python, but I tried this: import time import serial print('Code is Running.') # Make a ...
0
votes
0answers
5 views

peewee, how to query specified table?

i have peewee model, it need to create a table everyday, not i want to query table MotorTable.query() Test20191021 but it always query the table today, how can i query the specified table? DB = ...
0
votes
0answers
14 views

python3 pip fails to install jupyter on windows 10

I want to install jupyter on Win 10. I have been using python on linux, but this is my first time on Win 10. when I execute python -m pip install jupyter on administrator, I got errors like this: ...
0
votes
0answers
12 views

UnboundLocalError: local variable 'ext' referenced before assignment fetchProcess error

I am trying to fetch and process data I have created two functions fetch(), fetchProcess() fetch() is as follows def fetch(): root= tk.Tk() root.withdraw() filepath =filedialog....
0
votes
0answers
10 views

How do I insert a variable into a dynamically loaded module's namespace?

I'm trying to dynamically import a Python module at runtime, but I want the importing code to provide a missing a variable to the module that is being imported. The Python3 builtins module can ...
0
votes
1answer
21 views

How to attach logger from a separate module?

I've imported a python module, apex (from NVIDIA), which uses its own logger. Unfortunately those logged messages are not getting caught by my main logger, which also writes to a file. import logging ...
0
votes
0answers
10 views

Flask Migrations does not detect a field's length change

I have the next model class Client(db.Model): __tablename__ = "client" client_id = db.Column( db.Integer, primary_key=True, autoincrement=True ) name = db....
0
votes
3answers
45 views

Why are my python functions being called twice?

I'm fairly new to python and whenever I run my script, the first two functions humanPlay() and computerPlay() are called twice. I do not want this. I noticed when I comment out the draw variable ...
1
vote
0answers
8 views

Python indent output different for same code format

I have 2 codes with similar format but the "return value" need to be indented differently to get the correct answer, but I am not sure why this is happening. Explanations will be appreciated, thanks! ...
1
vote
1answer
13 views

Exclude a directory when building python .whl?

Given a python code base with 3 subdirectories: common, private, public, how do I build a python wheel file that excludes one of the directories? Specifically, I want to build a wheel file that ...
0
votes
0answers
12 views

Slow inserts to CloudSQL via SQL Alchemy in Python 3

I'm experiencing a weird issue, where I'm posting roughly 5k records to localshost MySQL db, then to CloudSQL instance. Localhost insert takes about 5 seconds, while CloudSQL takes ~5 minutes, and ...
0
votes
0answers
5 views

Failed to implement LIKE search on a Flask Web Application

Summary The web application created with Flask, Postgres, and SQLAlchemny I would like to input and search data, and the search is a partial match and results are displayed on the page. The data ...
0
votes
0answers
5 views

Running Hangman program, error says that 'correctLetters' is not defined and will not continue

Ive run into a frustrating issue for the 2nd time trying to figure out how to correctly run this Hangman game. My issue is I keep running into this error: Traceback (most recent call last): File "/...
0
votes
2answers
32 views

How to grab first child of its kind

I am trying to capture data from two nodes that have the same name. I am using the find method but it always pulls the value that is nested as opposed to the first child node. I've tried a few ...
0
votes
0answers
8 views

How to format a sql server 2017 merge query inside a for loop to populate query variables from pandas df columns

I'm trying to dynamically create a MS SQL EXECUTE statement to reuse across table ETL processes. So the number of string variables needed is reliant on the SQL file passed in the query variable. Here'...
0
votes
1answer
39 views

Making an in depth “quiz” for Dungeons and Dragons

I've been struggling to make a quiz with a randomized question bank where the questions will be able to increase a number of different counters (each question will be different in what they return). ...
0
votes
0answers
7 views

Different result of checking if connection is open in pymysql

Somehow, I get different result when I check is connection is open. After running the program, in the middle of his execution, I kill connection on server. First piece of code print me True, second - ...
0
votes
0answers
30 views

How can I only use one dictionary and be able to output a third value related to the key pair?

I've been set a task by my lecturer to complete a couple challenges to help improve my understanding of dictionaries and the concepts behind them. I've been able to complete the first task quite ...
0
votes
0answers
13 views

Is there any way to evaluate RMSE and MAE on out of bag data for random forest regressor

enter image description hereI am working with random forest regression model for my thesis work. My data set is small (about 3000 samples and 20 features) and it's over fitting on train data. Since ...
-1
votes
1answer
13 views

How do I find the max age from a csv file and then return that person's name?

The title pretty much sums up my issue. Here's the code I've got so far: def oldest_player(): #what is the name of the oldest player? for i in player_data: row_idx = player_data.index(i) ...
0
votes
0answers
10 views

Getting common rows of 2 files according to one column in python

I have 2 text files and I would like to make a sub-file from the 2nd file. in fact I want to get the common rows between 2 input files based on one column. this column has different names in 2 files ...
-2
votes
1answer
35 views

How to add a string and integer into a file and then sort it?

In my code the program asks for the users name and score. However I can send the score to a file and sort it. Is there any way to change the code so that the player name gets sent to the file and also ...
-2
votes
0answers
27 views

how to count how many values in a dictionary

Hello I'm new to python so I'm sure this is a simple answer but I'm trying to find how to count the number of values in a certain key in a dictionary from an input. I've tried something like: fruits ...
1
vote
1answer
18 views

How to pass date parameters to execute sql stored procedure in python pandas

This way works: import pandas import pyodbc import datetime as dt server = 'myserver' db = 'mydb' myparams = ['2017-02-01','2017-02-28', None] # None substitutes NULL in sql connection_string = ...
0
votes
2answers
37 views

Problems with tuples inside tuples

I have a tuple in which i want all the tuples inside the main tuple with the same length and in a codition, what i mean is that if that's True i want to return True else i want it to return false. The ...
0
votes
0answers
7 views

Filling tableWidget with alphabet letters

I am new to Python and everything is a bit different than I am used to. We got a homework about PlayFair cypher and I just want to fill TableWidget which is 5x5 with alphabet letters, which aren't in ...
-8
votes
3answers
49 views

Is there a way to access a variable from a calling function in python? [on hold]

I'm unsure if this is possible but I was wondering if there is a way to get a variable from an outer scope without passing it as an argument. I've played around with global() and inspect but i'm ...
1
vote
2answers
37 views

adding 1 to the previous row based on conditions

I have a pandas dataframe like below: data=[['A',1,30], ['A',1,2], ['A',0,4], ['A',1,4], ['B',0,5], ['B',1,1], ['B',0,5], ['B',1,8]] df = pd.DataFrame(data,...
0
votes
1answer
22 views

Assinging variable value to a new column in pandas DataFrame

I have created 3 new variables a,b and c based using certain conditions. Now I want to assign these variables to a new column in a pandas DataFrame again using some conditions. I want a code ...
0
votes
1answer
19 views

Why do the changes made in one variable result in the changes in related variables?

I have run a code as follows: data_model = data2 data_model.drop("Sale",axis = 1,inplace = True) This results in the removal of sale column from the data_model dataframe as well as the data2 ...
-1
votes
3answers
47 views

How can change the type of an array?

the title is a little bit wrong, but I had no idea what else I could use, sry. What I have: I have a function k with two inputs a and b with the same type "class 'numpy.ndarray'" and the same shape, ...
1
vote
0answers
9 views

No sound while playing mp3 with pygame

I wrote a script which plays audio when you press any key (that's a letter), but I'm not getting any audio, the script itself actualy works but I don't hear anything import os import keyboard, string,...
2
votes
1answer
27 views

How to make list comprehensions more readable?

I have this bit of code below, and i think it's kinda hard to understand if you are new to python. How would i go about making it more readable to a group of newcomers to python (students) def ...
-1
votes
2answers
30 views

Why 5 is greater than 10 python?

while True: x = input().split() if len(x) != 2: continue a, b = x if a > b: print(a, 'is greater than', b) Hi, why when i input: '5 10', output: '5 is greater than ...
0
votes
1answer
28 views

Is there a way to run a while x amount of times at the same time

I have a while loop where something has 99 hp, i want it to randomly "hit" it till its 0, now i want to do this lets say a million times to check on differences. Is there a way to do multiple of these ...
1
vote
1answer
15 views

Combine rows with same datetime while keeping columns intact

new to Python and coding. I'm struggling on how I could approach this. I have a dataframe formatted as such: Timestamp A B C 00:00:00 NaN NaN 15.67 00:00:00 NaN 1.66 ...
3
votes
3answers
32 views

Can't getting the implementation of __repr__() method in python

I was reading the famous book on python named 'python cookbook' by David Beazley and Brian K. Jones. In their 'classes and objects' chapter, they have written the following code: class Point: ...