Category "python"

How to resolve Key Error Exception when accessing dictionary key inside an if statement

I'm currently developing EV calculator using python and django. I get a key error exception when trying to access a dictionary key in an if statement inside a f

Using different instance of self as argument to method in python

I'm trying to create a method that takes self and another instance of the same method as its arguments, for example: class AClass(): def __init__(self

Iterate through pandas dataframe, select row by condition, when condition true, select a number of other rows, only containing unique values

I have a large (1M+) dataframe, something like Column A Column B Column C 0 'Aa' 'Ba' 14 1 'Ab' 'Bc' 24

How to scrape Trusted Shops?

I would appreciate your help on this scraping problem. I would like to scrape this site: https://www.trustedshops.de/bewertung/info_XDAD39B874C275A0751198C2510C

Iterate through pandas dataframe, select row by condition, when condition true, select a number of other rows, only containing unique values

I have a large (1M+) dataframe, something like Column A Column B Column C 0 'Aa' 'Ba' 14 1 'Ab' 'Bc' 24

Python docstring convention for private properties

Is it necessary to write a docstring for private properties? https://peps.python.org/pep-0008/ says that "Docstrings are not necessary for non-public methods, b

Discord.py bot not sending messages in a discord server but sends messages in DM's

I have a discord.py bot that when the command is sent through DM, it works. When the command is ran through a server, nothing happens. There is no errors or tra

'bytes' object has no attribute 'condition'

I am trying to stream my Rpi (zero) camera (v2.0) to HTML using cv2.VideoCapture. However, I am facing a lot of errors and I'm currently stuck on this one as th

How do I implement rank function for nearest values for a column in dataframe?

df.head(): run_time match_datetime country league home_team away_team 0 2021-08-07

docker discord.py ffmpeg.exe was not found

My code works on windows fine I'm just stumped on how to migrate it to my docker server for stability reasons and my old vm shit the bed. bellow is my main play

'bytes' object has no attribute 'condition'

I am trying to stream my Rpi (zero) camera (v2.0) to HTML using cv2.VideoCapture. However, I am facing a lot of errors and I'm currently stuck on this one as th

How can I get a variable valued current working directory (pwd) in powershell profile

I was trying to use anaconda as my Python virtual environment, and my virtual environment is stored in project directory. Manually, I need to use following comm

Why are orders in my trading algo not working? (QuantConnect algo)

I'm currently learning and trying to build my first algo which is a variation of an opening range break on the SPY. Would anyone know why my orders aren't worki

Which is the best way to represent my data

I have a following data structure: Page0 Key0 Text Color Name Key1 Text Color Name Page1 Key0

Proper automatic logarithmic axes when plot range less than a factor 10 (Matplotlib)

When the data range of logarithmic plots does not include a full factor of 10, the current (v3.5) Matplotlib code does not automatically produce publication-qua

What Python packages am I missing?

I'm trying to get my local Windows 10 PC up and running with my Django application. I'm a novice at Python and Django. My app was written by another developer w

python remoteconfig unable to parse file from Gitlab

I am trying to get remoteconfig working, following this guide: https://pypi.org/project/remoteconfig/ As a control, I have this code that works: config.read('./

Altering an immutable object?

def add_alpha(tuple_in): list_out = [] for t in tuple_in: t.append(10) a = ([1,1], [2,2], [3,3]) b = a print(id(a), id(b)) add_alpha(a)

How to create a curved line vector plot of a triangle in Python?

Question Suppose one has 3 random coordinates with 3 random functions that describe the continuous lines between them*, how would one create a vector plot in Py

How to check if dictionary keys match dictionary values in order

I'm trying to see if each key/value pair of a dictionary match, with the resulting output being True or False. I thought the below code would return True becaus