Category "python"

python -- pandas dataframe to nested json with hierarchy level

To be able to generate a checkboxes, I need to convert pandas DataFrame to a JSON format. First, I have a pandas Dataframe: cast title type Daniel Craig Sky Fa

Print data from Class instance

I want to print out data from a Class instance. I tried including data in str function, but this only works when value is at its default (an empty list). After

Find the center of Curvature of a point on 3D b-spline using nurbs / geomdl in python

Once again I am in over my head so please bear with me. I have a B-spline (imported from Solidworks) that I can analyze with geomdl in python. From geomdl I can

Right way to use RFECV and Permutation Importance - Sklearn

There is a proposal to implement this in Sklearn #15075, but in the meantime, eli5 is suggested as a solution. However, I'm not sure if I'm using it the right w

Scikit-Spatial Gives Weird Best-Fit Plane using Plane.best_fit

I am using scikit-spatial to find the best-fit plane for a list of 3D points. It usually works well for other lists, but this one is giving me a bit of trouble.

How to use selenium for webscraping google flights?

I'm trying to pull the airline names and prices of a specific flight. I'm having trouble with the x.path and/or using the right html tags because when I run the

Categorize and order bar chart by Hue

I have a problem. I want to show the two highest countries of each category. But unfortunately I only get the below output. However, I would like the part to be

How can I calculate the number of geodesics (shortest paths) going through a vertex or an edge in networkx?

The betweeness function in igraph of R defines the edge betweeness as the the number of geodesics (shortest paths) going through. However, the edge_betweenness_

Running Python scripts in Slurm

I've recently started a new job and need to run some scripts on the HPC through Slurm. My scripts are written in Python, and therefore I want to execute these u

psycopg2.errors.InsufficientPrivilege: permission denied for relation django_migrations

What my settings.py for DB looks like: ALLOWED_HOSTS = ['*'] DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql_psycopg2',

My for loop breaks and repeats the output over and over, also I cannot use Dictionaries in this

My code is a WW2 fact machine and for example if you input "1939" the code should print "start of war". If you input a keyword like "Dunkirk" it should work the

Replacement in python package in Docker

GraphQL is still not supported in Django 4, so to use it I need to change the line: "from django.utils.encoding import force_text" to "from django.utils.encodin

Recursively creates dataclasses based in nested dictionary

I have a dataclass called Config that is created through the properties and values of a dictionary. Since this dictionary can have nested dictionaries, i would

How to generate numpy arrays with random regions with rectangular shape with random size?

I would like to generate a binary array (values are 1s and 0s) filled with rectangular regions. Something like this: a = np.array([0, 1, 1, 0, 0] [

Custom objective function for XGBoost including an external data column

I am using XGBoost in order to do a sales forecasting. I need a custom objective function, as the value of the prediction depends on the sales price of an item.

Saving a composite model that includes a custom layer results in error - None has NoneType, but expected one of: bytes, unicode

I'm trying to save a model which is a composite model of composite models. The first model is a sequential model of two sequential models. Both of the two sub-m

Why do I get a 'FutureWarning' with pandas.concat?

Does anyone meet this similar FutureWarning? I got this when I was using Tiingo+pandas_datareader? The warning is like: python3.8/site-packages/pandas_datareade

Colour codes in python are not formatting correctly

In Python 3.8.3 whenever I try to implement colored text in python like \033[1;93m it keeps on saying [32m. Can I have some help, because it doesn't usually hap

How to get `setup.cfg` metadata at the command line (Python)

When you have a setup.py file, you can get the name of the package via the command: C:\some\dir>python setup.py --name And this would print the name of the

Slack API - chat_deleteScheduledMessage not working

I have been trying to make a chatbot that schedules a message and then deletes the message before it would sent to the channel. Although, the scheduled message