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.
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 ...
asked 5 mins ago
kms
1,2391212 silver badges3737 bronze badges
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/...
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'
...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
asked 15 mins ago
Dio
22111 gold badge22 silver badges1010 bronze badges
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 ...
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 ...
asked 15 mins ago
lazarea
66777 silver badges1919 bronze badges
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 ...
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 ...
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 &...
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 ...
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 ...
asked 22 mins ago
compmonks
56588 silver badges2121 bronze badges
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 ...
asked 22 mins ago
Sarah
12344 bronze badges
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)...
asked 23 mins ago
Hermi
15711 silver badge66 bronze badges
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)
...
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 ...
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 ...
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 ...
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 ...
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
...
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 ...
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 ...
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 ...
asked 27 mins ago
ElRudi
1,70422 gold badges1414 silver badges2626 bronze badges
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": [
{
&...
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 -...
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 = '''
╔╗─╔╦═══╦╗──╔╗──╔═══╗╔╗
║║─║║╔══╣║──║...
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)
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 ...
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 ...
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(...
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 - ...
asked 39 mins ago
keg5038
34922 silver badges1212 bronze badges
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,...
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 ...
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 ...
asked 39 mins ago
Bawzevic
3911 silver badge55 bronze badges
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 ...
asked 41 mins ago
gsk308
3311 silver badge44 bronze badges
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 ...
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 ...
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 ...
asked 46 mins ago
not2qubit
11.3k66 gold badges7979 silver badges109109 bronze badges
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):
...
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.
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 ...
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 ...
asked 57 mins ago
Rene
47911 gold badge55 silver badges1717 bronze badges
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 ...
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....
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(...