Category "python"

How to parse a JSON/dict-like value from an Excel sheet and copy over to another column?

I have an Excel sheet, where data is entered in this format: {"id":"03CD2B3C22558D83","imp":6667, floor:7777} How can I in python read and extract a certain va

Can PySpark ML models be run on only parts of a dataframe, depending on a condition?

I have trained a logistic regression algorithm to match job titles and descriptions to a set of 4 digit numeric codes. This it does very well. It will form part

Clean python import statements

I've created a python wrapper for a REST API. The API has a lot of endpoints, so I created a single file for every endpoint. The general idea is that the user c

CAD Model rotations and translations in Dash VTK

I have been looking through the Dash vtk documentation to search for a way to open STL files in the browser and be able to translate and rotate those files usin

ECCODES build on Windows 11 fails on Generate step

I'm trying to build ECCODES C package (https://confluence.ecmwf.int/display/ECC/ecCodes+installation) on Windows 11 for further usage with python pygrib library

Bug in Weaviate - Update data object instance (Python Client)

I have a Weaviate instance running (ver 1.12.2) I am playing around with the Python client https://weaviate-python-client.readthedocs.io/en/stable/ (ver 3.4.2)

Pydantic Checking if list field is unique

Currently, I am trying to create a pydantic model for a pandas dataframe. I would like to check if a column is unique by the following import pandas as pd from

How to use dictionary data initialized in a "class" object

I expose the problem quickly: I have to create 3 classes. X Y and Z, inside X y and z are initialized as variables of class x but not as objects Y and Z. What i

Split / Explode a column of dictionaries into separate columns with pandas

I have data saved in a postgreSQL database. I am querying this data using Python2.7 and turning it into a Pandas DataFrame. However, the last column of this dat

convert matplotlib figure to 2-D Array to show in pyqtgraph.ImageItem

i find an example in this Link which show 2-D array in pyqtgraph.ImageItem. import matplotlib.pyplot as plt import numpy as np import pyqtgraph as pg def main(

Why does dask take long time to compute regardless of the size of dataframe

What is the reason that dask dataframe takes long time to compute regardless of the size of dataframe. How to avoid this from happening ? What is the reason beh

How to reduce the space between the lines in Jupyter Visual Studio Code Output?

I want to reduce the space between the lines when I print something in Jupyter visual studio code output. Current output I would like an output like Jupyter wh

Stuck in urls.py while migrating a website from Python 2 to Python 3

urlpatterns = format_suffix_patterns(urlpatterns, allowed=['json', 'html']) While running manage.py makemigrations, got this error and was stuck in this error

calculating average artist entropy given user prediction and tracks in recommender systems

I have to calculate average artist entropy of users. I have solved this task on a test case but I am not able to generalize it to more task cases. Shannon Entro

Pygame mouse position not precise enough to rotate the 3D scene

I need to rotate a 3D scene or a character using the mouse position: for example, if I move the mouse to the right, I want to turn to the right / the character

Convert dog ages to human years

it as been a long time without programming. I'm doing a function that converts the age of a dog to human years, but I'm getting some mistakes and I am not getti

Non contiguous array pointer traversing issue in pybind11?

Please does anyone have any idea why when I pass my 2 dim Numpy float64 (Double) array normally it prints row by row correctly, col1, col2, col3, col4 as I trav

Is there a simpler way to hide a message in text?

I'm a newbie in Python. I have a sample.txt with random generated numbers, like: 190372210335873910924370795570288776927025955114012905862203094277820432758989

Questions regarding creating a NetCDF

Beforehand: If something is unclear or you need more information, feel free to write in the comments, so I can try to deliver what you need. Unfortunately I don

What do the h31 and h32 terms in a homography matrix mean?

I have used the MOTION_HOMOGRAPHY function in OpenCV (python3.6) to register a pair of images, and I am trying to interpret the 3 x 3 warp matrix the function r