Category "python-3.x"

Updating a Value of A Panda Dataframe with a Function

I have a function which updates a dataframe that I have passed in: def update_df(df, x, i): for i in range(x): list = ['name' + str(i), i + 2, i - 1

Downgrade Python version in virtual environment

I am always getting the same error regarding TensorFlow: ModuleNotFoundError: No module named 'tensorflow.contrib'. I am actually using Python version 3.9 but,

python how to use string value for custom sort?

I have an datafremae like this time_posted 0 5 days ago 1 an hour ago 2 a day ago 3 6 hours ago 4 4 hours ago I tried this df.sort_values(by='time_p

I want to repeat a function indefinitely [duplicate]

I am working through some exercises on python and my task is to create a program that can take a number, divide it by 2 if it is an even numbe

ImportError: Couldn't import Django. PYTHONPATH

There was an error account.User that has not been installed but I solved this problem. After that, another error says The SECRET_KEY setting must not be empty.

Improve performance of LineString creation, that currently is created by a lambda function

I have a dataframe like this (this example has only four rows, but in practice it has O(10^6) rows): DF: nodeid lon lat wayid 0 1 1.70

Jupyter Notebook Installation on python 3.8 in ubuntu 20.04

Traceback (most recent call last): File "/usr/local/bin/jupyter-notebook", line 5, in from notebook.notebookapp import main File "/usr/local/lib/python3.8/dist

Unable to read a column of an excel by Column Name using Pandas

Excel Sheet I want to read values of the column 'Site Name' but in this sheet, the location of this tab is not fixed. I tried, df = pd.read_excel('TestFile.xlsx

Randomizing Sentences In Python

I not long ago finished my project which comments on a video based on a keyword on YouTube, it will pick a random comment using the random library. The program

Django models in admin return TypeError: bad operand type for unary -: 'str'

I'm working on a project using Django(3) and Python(3) in which I have added few models and added those models in admin.py, but when I open the admin panel and

With which library I can bind hotkeys in python code?

I have a function and I want to bind this function to "ctrl"+"alt". I already used pynput, but it reacts even on typical "ctrl" or "alt". How to realize it in..

Auto-enter a value when prompted from a Python Script

Say I have access to a Python script (of which I didn't create) that prompts for a user input and then runs some processing tasks based off the input before out

ImportError: cannot import name 'Message' from partially initialized module 'pyrogram.types' can not import it

I am using pyrogram in a program but when i run the program it gives import error i uninstalled and reinstalled it but the problem is still there. I am not able

python and BaseHTTPRequestHandler : add an empty favicon in the header of the generated page

On python 3.8, I created a minimalist python server for my students with BaseHTTPRequestHandler and HTTPServer from the module http.server When I go to the url

Creating new pandas columns from substrings in a list

I have data in a csv called 'Features' which is of this form: 0 [Shops: Close by, Passing trade: Yes] 1 [Lift: Yes, No of Bedrooms: 1, Bedroom 1 Dims:

Input() function works inconsistently, python 3.8.10, spyder 5.3.0, IPython 7.32.0

The code print("Some text") integer=int(input("Enter an integer: ")) is expected to print "Some text\nEnter an integer: " and read the users input, but some of

Crop colour image according to OTSU threshold

I have a colour image which I have sucessfully applied the OTSU thresholding method on its greyscale form to obtain the outline of the biscuit: Original Colour

Instruct WebApp using Django to run the code locally and return results

I am a newbie to web development and python scripts. I am learning to host python scripts using Django. I would like to know how to instruct Django to run the s

comment SQL query with variables in python

I'm working with Cloud Function. I have the following query working correctly: # this is working q = """ SELECT col1, col2 FROM `my_table` WHER

How to import other Python files

I have this file, abc.py: def asb(): print("Hello, ") def xyz(): print("World!") In my main.py file, from abc import asb from abc import xyz I want