Questions tagged [python-3.x]
USE ONLY IF YOUR QUESTION IS VERSION-SPECIFIC. For questions about Python programming that are specific to version 3+ of the language. Use the more generic [python] tag on all Python questions. Use the [python-2.x] tags for Python 2 questions.
309,579
questions
0votes
0answers
9views
Using matplotlib and PyQt5
I'm writing code to update a matplotlib graph in real time while embedded into a PyQt5 application. Separately, the two pieces of code (for the graph and the embedding of a still graph. Putting the ...
0votes
0answers
11views
how can I customize error response from aws authorizer function?
I have written a lambda authorizer function that calls two custom authorization services to validate the input token. So, from lambda authorizer, I want to return different possible messages for the ...
-1votes
0answers
14views
Why is my collision with Pygame not working properly? [duplicate]
So I'm making a little archery game for school. To check collision between the arrow and the targets I use the pygame.sprite.spritecollide() function, and the sprites are masked. This is the arrow's ...
1vote
2answers
32views
Selenium Select to return a list?
In python we have:
select = Select(driver.find_element_by_id('fruits01'))
But what if I want to have a list of all select tags and not just the first one?
I tried:
select = Select(driver....
-2votes
0answers
19views
How do I make it so that when I type something it responds with something in specific (python) [closed]
Im not looking for something like
username = raw_input("Enter username:")
print("Username is: " + username)
But something so that the output is:
User:hi
Output:hey there
User:wow
...
0votes
3answers
43views
functools.reduce in Python not working as expected
I would like to sum across keys of dictionaries nested within a list using the functools.reduce function
I can accomplish this WITHOUT the functools.reduce function with the following simple program:
...
0votes
1answer
18views
checking if message author has a certain role
I am making an automatic banning system with a discord bot.
So once a message with a steam id is placed into the channel, it will run through an API and ban them (I've got this working)
what I am ...
0votes
1answer
24views
Unable to compare the time field in dictionary to current time
I am learning python. I am trying to compare the date in Time field of a dictionary with the date in current_time and if it matches, i am trying to print the key , id in JIRA_ISSUE but however, ...
1vote
1answer
33views
Python Selenium How to Select from Dropdown?
I was testing my code over: https://semantic-ui.com/modules/dropdown.html
I wrote the following code in Python3 which finds all drop-downs in a given webpage and selects the last option for each drop-...
-4votes
0answers
13views
OSError: [Errno 22] Invalid argument: '01:11:37.png' [closed]
[enter image description here][1]
[1]: https://i.stack.imgur.com/2pCwf.png llll
0votes
0answers
16views
Function printing my 'else' without fulfilling the condition [duplicate]
im having trouble with the function bellow where i need to check if the 'key' input is already in the function parameter. only if the 'key' is already in the parameter that is passed my else should be ...
0votes
1answer
12views
Python 3 subprocess, how to read json file
I am trying to make a script that needs to be executed locally and connect to a remote server via SSH. So far, I believe the subprocess might do the trick, however, I am not able to open the JSON file ...
1vote
1answer
22views
Is there a "better" way to do conditional lookaround?
(?=(pattern1|pattern2)) (pattern1)? (pattern2)? pattern3|pattern4
This is what I have ended up with, and it works, but is there a more parsimonious method?
I want to find all strings that contain &...
0votes
0answers
3views
SparkSession Not starting
#Original Code-------
from pyspark.sql import SparkSessionspark = SparkSession.builder.appName('SparkByExamples.com').getOrCreate()
dept = [("Finance",10),("Marketing",20),("...
-4votes
0answers
29views
How do I delete an object? [closed]
I want to delete an object in Python.
class User:
# how many users
active_users = 0
def __init__(self, username, first, last, age):
self.username = username
self....
0votes
0answers
30views
Read tabular file with multiple headers and values
I have to read/stream a file which has multiple rows in between with headers:
It has one file header and corresponding to this only one row as file record.
And then it will have one/more batch ...
-2votes
0answers
23views
python import csv starting on line x and only import y columns (not using pandas)
I am looking to import a .csv file using import csv. I don’t want to use pandas. I would like to start reading the file on line 10 then don’t want the first column but start on the second column of ...
0votes
0answers
7views
i try click button "tweet" but i can't do nothin in new window
action = ActionChains(self.driver) find = self.driver.find_element
finds = self.driver.find_elements
#FADED = (By.XPATH, '//*[@id="homefeatured"]/li[1]/div/div')
faded = find(...
1vote
2answers
35views
Split string in Python while keeping the line break inside the generated list
As simple as it sounds, can't think of a straightforward way of doing the below in Python.
my_string = "This is a test.\nAlso\tthis"
list_i_want = ["This", "is", &...
-1votes
0answers
9views
Python AttributeError: module 'websocket' has no attribute 'WebSocketApp' on macOS Monterey 12.3
I'm writing a Binance bot in Python 3.9, using websocket.WebSocketApp, and it has worked for months. However, a week ago - when I run the script again I got the error above. I've tried all the ...
0votes
2answers
28views
String search on dataframe using key/value from dict
I am trying to match the string present in the below dataframe's 'Disease' column with the key from the dict and if the string is present then change the value in the 'category' column to the value of ...
-1votes
0answers
25views
python package contain file however it's missing after pip install [duplicate]
I have problem with correctly using setuptools in python.
my-app/
- src/
| - main.py
- dep.txt
In my project I have a dep.txt file which i add while building a python package in MANIFEST.in.
include ...
0votes
0answers
12views
maws2.0.py yield start ^SyntaxError: 'yield' outside function [duplicate]
The program maws.py was developed by students in 2015 at Uni-Heidelberg but I could not contact the developer. I checked maws.py with PyCharm and the many indentation problems were solved, I hope. ...
-1votes
0answers
37views
Python: no module named even sys.path includes it
I didn't find a solution from other posts:
I don't use relative path in my case, I use absolute path sys.path.append(os.path.abspath("../../set/tech"));
The path to the desired module is ...
-3votes
2answers
50views
ValueError: not enough values to unpack (expected 3, got 2) (OpenCV) [duplicate]
I have a problem with python program( line 22 -(_cnts_) ). I use win11, PyCharm. I am getting error ValueError: not enough values to unpack (expected 3, got 2).
import cv2, time
import pandas
...
1vote
1answer
37views
How to pass tuple with one element as param in sql query Python?
How can I pass tuple with only one element as param in sql query Python?
I have tried this solution suggested here:
imploding a list for use in a python MySQLDB IN clause
ids = [(UUID('1232a4df-5849-...
-1votes
1answer
24views
Python variable not registering with if statement [closed]
When I ask the user if they would like to mega size their order, python says that it is a invalid entry. Dont mind the choice[] list, it is used elsewhere.
print("What size would you like?\...
0votes
1answer
19views
How to use read_excel inside a loop?
when I use read_excel outside a loop it creates a normal dataframe:
pd.read_excel('file.xlsx')
but I need to parse files in order to create dataframes, like:
os.chdir('/path/to/dir')
for file in glob....
0votes
1answer
23views
Can I modify a python version inside venv without affecting that version outside of venv?
I want to modify some python39 packages inside venv, will this affect the python39 outside the venv?
0votes
1answer
17views
In dataframes created by a loop, add suffix to columns that increases with iteration
I am creating multiple dataframes numbered from 1 to n through a loop.
The first thing I do for this, is create a dictionary:
dict_of_df = {}
then runs the loop:
for i in range(1, n+1):
... ...
0votes
1answer
41views
Prevent blank line at the end of a text file [duplicate]
I have created a program in python that uses a .txt file as a database, so I save the user data there.
The data is stored in the file as follows:
Each line in the file represents a user
Users are ...
0votes
1answer
27views
Searching through a list of text files for the correct user and their information in Python
I'm very new to Python and I am making a simple program, which starts off with a menu. One of the options, once selected, will ask the user to enter a username. Once a username is entered, the program ...
0votes
1answer
22views
Create new data frame based on list of column from list
Consider a list with 2 values as shown below.
list_1 = ["Col1", "Col2"]
I have another data frame df which contains below value and has same column name i.e. Col1, Col2, Col3.
...
0votes
1answer
18views
How to filter blobs in Azure SDK for Python
I want to search for blobs in my Azure blob storage according to a specific tag (like: .name, .creation_date, .size...)
My current way is returning all blobs from the container with MyContainerClient....
0votes
0answers
4views
AWS Wrangler Error HIVE_METASTORE_ERROR: Table is missing storage descriptor
hope you can help me with a concern about an error with awswrangler.
this is the case: i have 2 aws accounts, AccountA and AccountB, both with lakeformation enabled, i have a set of databases in AccA ...
0votes
0answers
9views
Atfer lauching my Gui in my main program , it don't keep on [duplicate]
i create a little program with a GUi (PyQT5), my windows is programmed in my "Dailog.py" and all actions and calculations will be on my main...
But when i lauch my main which is calling my ...
0votes
0answers
31views
Python Pandas : How to read huge number of csv files from S3 bucket efficiently
I have 750,000 csv input files in S3 bucket which needs to be transformed and loaded into output folder which will also be stored in csv.
While I have a notebook which reads these many files , while ...
0votes
0answers
20views
TypeError: The error handler must be a coroutine. sys:1: RuntimeWarning: coroutine 'Command.__call__' was never awaited
I try to run my code and have this error , I was trying to do an error handeler on my discord py bot but it seems not working:
@A_lot_of_errors.error
async def error_handler(ctx , error):
coderror ...
0votes
1answer
25views
Subtract two datetime.time
i basicly need to get actual time(time1) and see how many hours and minutos to time2.
Its a countdown, how many time untill time2.
I have been making this
def schedule_task():
exp_h = 23
...
0votes
1answer
12views
Union many tables SQLalchemy
I have a list of table names with many tables (a few dozen) in a Postgres DB mapped to SQLalchemy ORM objects. All of them have common columns and I would like to union a sub-set of columns from all ...
0votes
0answers
7views
Save classification report & confusion matrix of for loop into csv file
I need to have 10 results in my CSV file but it shows only one. I looked through some questions posted and it said might be my previous iteration being covered.
How should I edit my code in order to ...
0votes
1answer
34views
Incomplete SQL Server CDC Change Table Extraction Using Batches
Basic issue: I have a process to extract records from a CDC table which is 'missing' records.
I am pulling from a MS SQL 2019 (Data Center Ed) DB with CDC enabled on 67 tables. One table in particular ...
0votes
2answers
34views
How to read txt files with those languages which is read from right to left with python
Here is a code that is reading a file for me. But each word of the file is reversed from the original text that I have put in line.txt file.
line.txt
اور ایک
test.py
import re
f = open("line....
-2votes
0answers
22views
how to unbold a text in python? [closed]
I am trying to unbold a text using python.
the text is
print("the text is ",bold_item)
the text is Python
print("unbolded text is",unbolded_text)
and the expected result is
...
0votes
4answers
55views
Dataframe: create pairwise difference
I have this dataframe:
Name
Score 1
Score 2
Score 3
...
Score 20
Max
2
3
5
...
2
Jacob
1
4
3
...
6
How do I get the pairwise difference? So the result should look like:
Name
Score 1-2
Score 1-3
...
-2votes
1answer
46views
Create a List from a string in Python
I am new to pyhon and i can't find a way to manipulate a string of mine into a List.
I read a file that contain this exact output (it is one parameter of a csv file):
[{a,b,c},{aa,bb,cc}]
I want to ...
0votes
0answers
21views
How to install a specific version of libpython on linux
Prefix: I am currently working with some legacy machines in the field and need to install specific versions of libpython. These machines do not have access to the internet so apt-get or pip is not an ...
1vote
1answer
20views
Multiply a [3, 2, 3] by a [3, 2] tensor in pytorch (dot product along dimension)
Given the following tensors x and y with shapes [3,2,3] and [3,2]. I want to multiply the tensors along the 2nd dimension, this is expected to be a kind of dot product and scaling along the axis and ...
0votes
0answers
23views
Is it possible to build a Windows .exe or Mac .dmg from a Linux only system? [duplicate]
I wrote a small encryption application in Python. Using PyInstaller, I created an executable Linux file that runs the application without the need to have Python installed. Now, I am trying to create ...
-1votes
1answer
26views
Take 2 random dates from list of dates based on days range condition
I would like to randomly choose 2 dates from the list of dates based on condition that if date range between 2 randomly choosen dates from the list is lower than 100 days we want to take them if not ...