Questions tagged [python]

Python is a multi-paradigm, dynamically typed, multi-purpose programming language. It is designed to be quick to learn, understand, and use, and enforces a clean and uniform syntax. Please note that Python 2 is officially out of support as of 01-01-2020. Still, for version-specific Python questions, add the [python-2.7] or [python-3.x] tag. When using a Python variant (e.g., Jython, PyPy) or library (e.g., Pandas and NumPy), please include it in the tags.

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

python or js code / library to export html elements of a Flask/Dash App

I have running a Flask Application with embedded Dash App. The application code is entirely written in python that renders html code. Now, I'd like to be able to export certain <html> elements ...
-3
votes
0answers
10 views

Rotate a robot 45 degrees [closed]

I am working on a robot that should rotate 45 degrees,but i can't actually find the formula between the time and rpm. I use 4 dc motors "https://www.amazon.com/Antrader-Motor-Shaft-Arduino-Smart/...
0
votes
0answers
7 views

Problem in output shape of the BiLSTM predicted values

I'm training a tensorflow model to predict spam messages using a BiLSTM. The model is being perfectly trained with no problem. When I run the following code PAD_TYPE = 'post' TRUNC_TYPE = 'post' ...
0
votes
1answer
18 views

How to type annotate a function pointer (function variable) in Python?

Let's say I have a function that has type annotations and then a variable (pointer) to that function: def some_func(arg1: str, arg2: int = 0, arg3: str | None = None) -> List[Any]: # do ...
0
votes
0answers
6 views

ElasticSearch tutorial: Getting ValueError from bulk_indexing

I am following this tutorial. https://medium.com/free-code-camp/elasticsearch-with-django-the-easy-way-909375bc16cb#.le6690uzj Tutorial is about using elasticsearch with django app. I am stuck when it ...
0
votes
1answer
16 views

Indexing in python (enumeration method)

Light question in the evening :D string = 'S40S' for char in string: print(string.index(char)) #Returns 0 1 2 0 If I want to receive the index of a certain string. Why would the index of the ...
0
votes
0answers
7 views

How to use the optimizer in tensorflow2 correct?

Im asking myself does the following code do only one step of gradient descent or does it do the whole gradient descent algorithm? opt = tf.keras.optimizers.SGD(learning_rate=self.learning_rate) opt ...
0
votes
0answers
16 views

NameError: name 'Complex' is not defined [duplicate]

I cannot understand why this code is showing errors. Sorry if there is same question asked before. class Complex: def __init__(self,r=0,i=0): self.real = r self.img = i def ...
0
votes
1answer
8 views

Download google drive email attachments using python

I have found a simple script online to download email (gmail) attachments from unread emails. This scripts works great with files under the 25MB limit. When files are send over 25MB google will send ...
0
votes
0answers
7 views

How to show an input on GUI tkinter

So I just want to make a simple table where the user inputs values for the mean, min, and max. This will then be displayed on Tkinter. I think I am almost there, but for some reason, I cannot seem to ...
0
votes
2answers
10 views

python: Cant expose flask app in docker container

I have a Flask app that works localy but i cant get it to work running in a docker container. Structure of the project: Contents of the Dockerfile: FROM python:3.9 ENV PYTHONDONTWRITEBYTECODE 1 ENV ...
0
votes
0answers
6 views

Trim pyaudio recording

I am working on a project that involves getting audio input from the user and storing it for further processing. I have been successfully using pyaudio for this purpose. Now I began optimizing the ...
0
votes
0answers
3 views

Python pitch modulation (not shifting)

I want to augment my audio data for a machine learning project. I am looking for a way to gradually modulate pitch of an audio clip to simulate the Doppler effect. From what I can see Librosa and ...
0
votes
0answers
11 views

How to binding to local time to run code?

for admins StackOverflow, please do not delete this question, because I did not find a solution or good example here, although the question is quite common. If we are using Python + Linux + Cron it is ...
0
votes
0answers
9 views

ImportError: cannot import name 'to_catagorical'

When I try to run: from tensorflow.keras.utils import to_catagorical I get this error: Traceback (most recent call last): File "/home/pi/Desktop/Processing_Data_Commands.py", line 3, in &...
-4
votes
0answers
19 views

How to build a machine learning model in one day? [closed]

I'm in my job right now and put hello world on my resume and now my boss thinks I'm some sort of machine learning expert. Please help. It is due in one day and I really need some help with this. The ...
0
votes
0answers
8 views

pdf background read from pdfrw returns Nonetype

With pdfrw I am trying to merge two pdfs to add a background (a pillow image saved as pdf) to an existing pdf generated by reportlab. It seems easier that way to control which background goes on which ...
0
votes
1answer
12 views

setting values in numpy matrix with array of indices

Consider a mxn matrix A. I computed the indices of the maximum of each row, yielding an array of dimension m. How can I use this array of indices to set the values in a second matrix B of the same ...
0
votes
0answers
3 views

CPU: Problems with Python module torch.multiprocessing

Let me provide you with a MWE of a simple test of torch.multiprocessing: import torch import numpy as np import torch.multiprocessing as mp def square(i, x, queue): print('In process {}'.format(i)...
0
votes
1answer
20 views

Big O Complexity Python, find out running time for input of size 'n'

For this functon, I am to select the most appropriate Big-O running time for input of size n: def 2d_list(n): i = 0 data = [] while i < n: data.append([i] * n) ...
-1
votes
0answers
4 views

How to scrape the confirmation sign in Python on EarningsWhispers?

On EarningsWhispers, I would like to scrape (in Python) the '(confirmation) sign' of the earnings date. Screenshot of the confirmation sign This is the code I am currently having : from bs4 import ...
-1
votes
1answer
13 views

I have problem with wget module in python

can anyone solve my code pls? Im too begginer Also, I would be very happy if you tell me how I can do it more efficiently without having to create a different function for each file type. (You can ...
0
votes
0answers
8 views

Vizualize distance matrix into graph

for the folowing distance matrix ∞, 1, 2 ∞, ∞, 1 ∞, ∞, ∞ I would need to vizualize the following graph That's how it should look like I tried with the folowing code import networkx as nx import numpy ...
0
votes
0answers
6 views

Bayes theorem and multiple dice combinations

i am new to coding and statistics, and can't find a way to create a code that could print me the probabilities based on the hypothesis made in the exercise below. "You are playing a heated game ...
-3
votes
1answer
19 views

I have a password manager and it doesn't work correctly

def main(): print("Hello to your password manager") i = input("what do you want to do? generate password(gen)/add password(add)/view your passwords(view) : ").lower ...
-2
votes
1answer
18 views

Updating Value in a list of dicts appears to not work

some_key in dictionaty data is a list. some_key contains a list of dictionaries. I would like to update the value of one of the keys in this list for each item. Below is my solution to update the ...
0
votes
0answers
7 views

How can I automatically calculate the formulas of an Excel file made with OpenPyxl?

I'm working on an program which makes an excel file, then it gets the info into JSON and does more things. I'm struggling with Openpyxl. I found out today that if you don't open an Excel file made ...
1
vote
0answers
13 views

String formatting not working when accessed through dictionary

I try to create a dictionary of string formatting lambda functions, but for some (to me) obscure reason, it's not working, and the incorrect value is retrieved from the dictionary; see the use of the ...
-1
votes
1answer
21 views

Array in a json

I am creating a python project who are working with an api, the api return an json like this : "1": "2018-10-13T08:28:38.809469028Z", "result": [ { &...
0
votes
0answers
10 views

Is there a way to play .mp4 and .mkv files with QMediaPlayer?

tl;dr: I'm (on windows) using QMediaPlayer with PyQt5 to create a video player I can control with python, but it's only playing .avi files, and I need to play .mkv, .mp4 and .MPEG. Important notes: 1 -...
0
votes
0answers
13 views

Python template strings in curses

I am making a game using curses on python. My code is: from curses import wrapper import curses def main(stdscr): score = 0 stdscr.erase() text = ''' ╔╗─╔╦═══╦╗──╔╗──╔═══╗╔╗ ║║─║║╔══╣║──║...
-3
votes
0answers
18 views

How Can I Solve This Problem in my code error? [closed]

def culeyska(dhirirka, culeyska): bmi = culeyska / (dhirirka**2) print ('bmi') if bmi< 25: return 'ma buurnid' else: return'waa buuran thy shuluq yahooow' culeyska(1.84, 85)
-3
votes
0answers
14 views

Comment tester si un fichier est ouvert en python? [closed]

Bonjour. Je réalise un gestionnaire de fichiers et je voudrais pouvoir interdire une action (copier, renommer, supprimer) sur un fichier lorsque celui-ci est ouvert(ouverture d'un fichier texte avec ...
-2
votes
0answers
24 views

How to create new namedtuple in a for loop [duplicate]

My question is around creating a new namedtuple instance inside a for loop. The key is that I want it to be available OUTSIDE, the for loop. This is what I have so far: n = int(input()) #split the ...
0
votes
0answers
6 views

Trying to categorize e-commerce customers using clustering and NLP

I have used TF-IDF and K-Means clustering and optimized its number of clusters as well using silhouette and elbow rule for SSE. This produced an OK result. However my data has a lot of words(...
0
votes
0answers
8 views

Iterate Over Dictionary to Combine PDFs, Rename

I am attempting to create a function that combines pdf files into a single file. I am attempting to take a dictionary that is constructed as follows: mydict = {"001 Pre-Op - Production Run Form - ...
-1
votes
2answers
23 views

How remove zeros and round multiple columns in a pandas dataframe

I have a pandas dataframe like this: df = pd.DataFrame([ {'A': 'aaa', 'B': 5.56000000, 'C': 0.01000000, 'D': 1.00000000, 'E': 0.00001000}, {'A': 'bbb', 'B': 0.49000000, 'C': 0.00100000,...
0
votes
0answers
3 views

Telegram bot output as a list, formatting help required

I am building a telegram bot and now i want to display my outputs as a list here is the code: def help(update: Update, context: CallbackContext): update.message.reply_text("/crypto - This ...
-1
votes
2answers
23 views

Python: Fill data in a list in a tuple

I need to create a function that reads the data given and creates a list that contains tuples each of which has as its first element the name of the airport and as its second and third its ...
0
votes
0answers
7 views

how to add variables into neo4j cypher code inside python

I am trying to get a function argument into the cypher code in my python function. The function takes 3 arguments and adds a relation ship of given type between the persons and is as below (the ...
0
votes
0answers
3 views

loading sequenceTagger of (bigger) language models in flair kills kernel

I am rather new to NLP and especially to flair so I came across this issue while trying to work through the flair tutorial provided on their github-page. Everything worked just fine as long as I used ...
-1
votes
2answers
26 views

How can I check if an input is a number and then turn it into an integer?

user_input = input("Press [A] or type 1").lower() if user_input ???: user_input = int(user_input) elif user_input == "a": ... i want to check if the user input is ...
0
votes
0answers
12 views

How to get the current text cursor position from Python in a Windows Terminal?

Getting the current mouse pointer position in Python is trivial, through the use of the Windows API ctypes libraries. However, it seem that taking the step from the mouse pointer's screen position ...
0
votes
1answer
15 views

Not able to setattr using class.__setattr__(key,value)

I have my code like this one: class __Metadata(type): def __init__(cls, name, bases, dict): super().__init__(name, bases, dict) def __setattr__(self, key, value): ...
-1
votes
1answer
14 views

Pandas manipulate data points [duplicate]

Hello everyone, I would like to redesign the date column. It should be date format instead of 201501 but I couldn't handle it. Could you please help me? Thanks in advance.
0
votes
0answers
13 views

How to dinamically change import locations in python?

I am coding a set of modules in python. My folder structure is: project ..../module1/ ........Package-1 ........Package-2 ........Package-n ....main.py I have set outside of the main class of each ...
0
votes
0answers
2 views

How can I set up the correct color image color in datashader?

I have tried to plot a given example from the datashader page about Timeseries. Therefore, I have copied the code and tried to plot it with matplotlib by adding the following code snippet: import ...
1
vote
0answers
4 views

Rasa customs policy do not work with rasa shell in cmd

I have a small problem with a customs policy in rasa for actions. I build a policy that selects the actions randomly, however when use the command "rasa shell" and chat with the bot, it does ...
0
votes
2answers
23 views

How do I plot countplot using the same column from multiple similar datasets?

I am trying to plot a countplot with seaborn using multiple datasets which were sliced from a single dataset( "heart.csv" ). I am getting a perfect countplot using this code below df = pd....
-1
votes
0answers
15 views

def on_member_join not working discord.py 1.17.3

I am making a discord bot with python. However, the on_message_join function doesn't seem to work. This is my code: import discord client = discord.Client() @client.event async def on_member_join(...

1
2 3 4 5
37403