Category "python"

How to write and read custom objects to and from Redis with Python?

I have an ordered dictionary where the values are of a custom type object (for example datetime.datetime) and I want to cache it to Redis. What is a good and se

Groupby and create a dummy =1 if column values do not contain 0, =0 otherwise

My df id var1 A 9 A 0 A 2 A 1 B 2 B 5 B 2 B 1 C 1 C 9 D 7 D 2 D 0 .. desired output will ha

Importing pandas_profiling

I am working on Automating the EDA, while I want to import the pandas_profiling, I am facing an error: ImportError: cannot import name 'soft_unicode' from 'mark

How to get rid of prompt line in IDLE IDE 3.10?

There's a line in IDLE IDE in 3.10 version on Windows, which did not exist in prior versions. Is there a way to get rid of it? I have tried changing themes but

Jenkins build failing without updating Xray with the failed status

Please forgive me if this is not the place to ask this question. I'm running python scripts in a Jenkins pipeline from a Jenkinsfile. I am also updating Jira Xr

Why can't dunder/magic methods be set in unittest.mock.Mock.configure_mock?

I was writing some unit test in python and needed to mock a very general collections.abc.Sized, so I set off creating a Mock with a __len__ method whose return

mixed effect model with more than two uncorrelated random effect slopes in python

I have multi-level data and want to fit a mixed-effect model in python due to parallelization potential. But I am not able to compile the formula in 'statsmodel

How to edit and save TOML content in Python

I would like to edit a local TOML file and save it again to be used in the same Python script. In this sense, to be able to change a given parameter in loop. Yo

How to raise an exception when a string isn't comma-separated

I want it to raise an exception and print Invalid input if the input string is not separated by commas. However, this is not raising an exception. try: stri

Pandas Lookup to be deprecated - elegant and efficient alternative

The Pandas lookup function is to be deprecated in a future version. As suggested by the warning, it is recommended to use .melt and .loc as an alternative. df =

Use a list with function names to iteratively apply over a dataframe column

Context: I'm allowing a user to add specific methods for a cleaning process pipeline (appended to a main list with all the methods chosen). Each element from th

Bootstrap tabs doesn't work with Django include option

I am working with bootstrap tabs in Django on page ps_tabs_capacity.html which extends the base.html . Inside ps_tabs_capacity.html there is tab I include anoth

Connecting OHIF viewer to Orthanc Pacs Server

Orthanc is running on port 8042. I have run the following commands to view the images in my Orthanc pacs, through the OHIF viewer which is running on port 3000

Policystatement is getting generated while adding SNS destination to Lambda

I have a create-lambda stack and i am adding an existing SNS topic as the destination thru CDK + Python. While deploying the code i am getting an error The func

AttributeError: 'numpy.ndarray' object has no attribute 'columns' even after using pandas dataframe

import pandas as pd import matplotlib.pyplot as plt from sklearn.model_selection import train_test_split,cross_val_score from sklearn.tree import DecisionTreeCl

Append new data into an existing frame and upload to sheets Python

I'm connected to my APIs client, sent the credentials, I made the request, I asked the API for data and put it to a DF. Then, I have to upload this data to a sh

Python - Hours between two dates, excluding weekends

I'm doing my first steps in python programing language. I want to create a script that aims to open an excel file and add an extra column that will be the hourl

Scraping newspaper article titles with google news

Below is my code for scraping news about domestic violence. This code worked perfectly the first time I used it. But back then I covered only 2-3 months period,

PySpark SQL forbid certain functions/operators

Given a PySpark SQL such as park.sql('''select 10%4 as hello ''') what is the best way to throw an exception anytime an operator % is used?

Python Loop (pyautogui)

Hii,I want to create a loop to fill an excel table with another and stop when it finds an empty field, which in this case would be the first ctrl+c as a referen