Category "python"

How to test multiple variables for equality against a single value?

I'm trying to make a function that will compare multiple variables to an integer and output a string of three letters. I was wondering if there was a way to tra

Multiple aggregations of the same column using pandas GroupBy.agg()

Is there a pandas built-in way to apply two different aggregating functions f1, f2 to the same column df["returns"], without having to call agg() multiple times

how to only get the alphabet letter from a string in python [closed]

I'm trying to create a program that takes in text from a file and outputs the frequency of each letter. The output also shows the frequency of

How to slice a XGBClassifier/XGBRegressor model into sub-models?

This document shows that a XGBoost API trained model can be sliced by following code: from sklearn.datasets import make_classification import xgboost as xgb bo

How to slice a XGBClassifier/XGBRegressor model into sub-models?

This document shows that a XGBoost API trained model can be sliced by following code: from sklearn.datasets import make_classification import xgboost as xgb bo

a python console application executed from within vscode integrated terminal not allowing arrow keys to select list items

I have a file samlapi.py. Running the file pops up a dialog with a list of menu items on the terminal to select from. I cannot traverse the menu items using key

Cryptographically secure pseudo random shuffle a list or array in python

I am in need of a shuffle function that uses CSPRNG (Cryptographically Secure Pseudo Random Number Generator) and can be seeded manually for the same output for

Delete (a, b) in dictionary_1 if a in dictionary_2

I have two dictionaries D1 = {('one', 'two'): 3, ('three', 'four'): 5, ('five', 'six'): 7, ('eight', 'nigh'):8} D2 = {'one':1, 'five': 2} I want to delete ('o

Pytube Error: get_throttling_function_name: could not find match for multiple

I am trying to download YouTube playlist from url "https://www.youtube.com/watch?v=uyVYfSNb_Pc&list=PLBxwSeQlMDNiNt72UmSvKBLsxPgGY_Jy-", but getting the err

I have plotly dash app, and get this error: Cannot read properties of null (reading 'layout')

I have web app in plotly dash. I have 3 dropdown and graph with selected item. When I change category i have error: Cannot read properties of null (reading 'lay

How can I create a cross-tab of two columns in a dataframe in Python and generate a total row and column in the output?

I have created a dataframe from a CSV file and now I'm trying to create a cross-tab of two columns ("Personal_Status" and "Gender"). The output should look like

Using Yolox on an asset image doesn't draw any detection

So I'm trying to learn how to use Yolox for my bachelor thesis, and after hours of installing and updating components, finally managed to run Yolox on a test im

sort two nested lists according to value of one list in python

I want to sort two nested lists according to value of one list. predictions = np.array([[0, 1, 2, 3], [3, 2, 1, 0], [1, 2, 3, 0], [-1, -1, -1, -1]]) test_intera

Run generator when button is clicked

I want to create a Button to generate a password with tkinter but when the script is running, the password is already generated and the button doesn't work. Her

Extracting data from a .txt file without using modules

I am taking a course in python and one of the problem sets is as follows: Read in the contents of the file SP500.txt which has monthly data for 2016 and 2017 a

Tkinter get rid of the python icon in messagebox tkinter

How can I get rid of the Python (or matplotlib) icon when running this code? Even when I add icon='info', I still get the rocket with the python logo. Please ch

How overload < and [] operatot on Python

Recently OOP has moved from C++ to Python. I know the basics of the language more or less, but I had to work with OOP for the first time. The task is as follows

pygame.examples.aliens not working (syntax error)

If i try to run the example code "python3 -m pygame.examples.aliens" i get a syntax error (see code bellow). I thought that i didn't install pygame correctly bu

XML: delete unwanted tags but keep text content

I am trying to tidy up a corpus with way too many tags. To do this, I want to filter out/remove the useless tags but keep the text content. I'm quite new at wor

Add hours from input , Datetime/Timedelta (Python)

I'm trying to make a script to go to a website and enter in a time in a 24 hour format. I'm using the pyautogui module to perform the web tasks, and Datetime/Ti