Category "python-3.x"

How to convert amplitude to dB in python using Librosa?

I have a few questions, which are all very related. The main problem here is to convert the amplitude of an audio file to dB scale and I am doing it as below wh

Flask-SocketIo always using Polling

I have made an web app with flask and implemented socket-io in it using Flask-SocketIO but it is continuously using Polling method instead of Web Sockets. My JS

How to attach mulitple files in PDF?

I have a list of objects: List = ['Doc1.xlsx','Doc2.csv','Doc3.pdf'] and a list of their names: List1 = ['Doc1_name.xlsx','Doc2_name.csv','Doc3_name.pdf']. I ne

Can't establish SSL connection to Kafka after upgrading to python 3.7

Code I have that successfully connects to Kafka with an SSL connection in Python 3.6.7 fails when using Python 3.7.3, with error message SSL: WRONG_VERSION_NUMB

Running a string command using exec with popen

I have a simple cmd_str containing a set of lines. Using exec, I can run those lines juts fine. However, running those lines in a separate process when shell=Tr

How to create a requirements.txt file in Django project?

I have been trying to create a requirements.txt file from the Pycharm terminal but it is adding all unnecessary packages as well. What should I do to show only

OpenCV AttributeError module 'cv2.cv2' has no attribute 'Tracker_create'

I have tried to run this code but get an Attribute Error. Any help would be greatly appreciated. import cv2 import sys (major_ver, minor_ver, subm

Trying to send screenshot over sockets using pyautogui

I tried to send screenshot, but when I get the screenshot I get this picture on my screen, instead of normal one... What am I doing wrong? Server: elif data.

How does a Python class within another class work w/o Inheritance? (Python Beginner)

I'm a python beginner just ran threw a book that includes this MiniProject at the very end.The exercise reads: Your task is to create a deck of cards class. Th

How to get nested dict from argument_group

I wanted different part of the program to see only the necessary args parsed. parser = argparse.ArgumentParser() log = parser.add_argument_group() log.add_argum

tensorflow_probability: TransformedDistribution not accepting event_shape and batch_shape arguments

In version 0.11.0 of Tensorflow Probability, I can define a TransformedDistribution as follows, indicating event and batch shape: mvn = tfd.TransformedDistribut

tensorflow_probability: TransformedDistribution not accepting event_shape and batch_shape arguments

In version 0.11.0 of Tensorflow Probability, I can define a TransformedDistribution as follows, indicating event and batch shape: mvn = tfd.TransformedDistribut

Nesting long lists and sets using black formatter

Can the python black formatter nest long lists and sets? For example: Input coworkers = {"amy", "bill", "raj", "satoshi", "jim", "lifeng", "jeff", "sandeep", "m

Use of Replace() in Python Dataframe for Multiple Columns but same value

Query: I need to replace the 1 old value with the 1 new value for a bunch of columns (not all columns) in a dataframe. The question is about the syntax to be us

How to quickly get the last line of a huge csv file (48M lines)? [duplicate]

I have a csv file that grows until it reaches approximately 48M of lines. Before adding new lines to it, I need to read the last line. I tried

Python label encoding : Decision tree classification

Im really new to Python and am trying to run a decision tree model with the below query: from sklearn.metrics import classification_report, confusion_matrix fro

Error while popping out Flask app context

I am trying to create an async API using threading (Celery is an overkill in my case). To achieve the same, I subclassed the Thread class in following manner. S

Convert a Python block of code into a single line

Below is the python block code, def compute_hcf(x, y): while(y): x, y = y, x % y return x which I wanted to convert into single line like below, d

python - remove space in the end of range loop (int)

Its quite simple but I got stuck. I have two files who need to be identical(even spaces) file #1 is the output from : for i in range(0, 19): print(i)

Python write dictionary to csv with header

I want to write a specific python dictionary to csv with header. I have looked at other questions but none of them have the similar dictionary structure as mine