Category "python"

Annotate bars with values on Pandas bar plots

I was looking for a way to annotate my bars in a Pandas bar plot with the rounded numerical values from my DataFrame. >>> df=pd.DataFrame({'A':np.rand

How to get list of palindrome in text? [closed]

I have the following interview question that may require traversing through the entire string. Problem I searched about find Problem and most

starting container process caused: exec: "uvicorn": executable file not found in $PATH: unknown

I'm trying to Dockerize my FastApi app, but it crash with this error right after I run the command, docker-compose -f local.yml up -d. Some one can help me plea

Converting Complex Tree Structure to JSON Python

I need to convert a Tree with the following class structure: Class Tree: def __init__(self, data): self.data = data s

how to capture logger values using clearml

I am using clearml for testing algorithms and it works well with library Stable Baselines 3, in which clearml automatically captures all the output and plot the

connecting to a different google drive than the one logged into google colab

recently colab removed the ability to connect to google drive from different accounts other than the one you were logged into in google drive. There was a worka

Keep getting "ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all()."

data_df.loc[data_df['hotelID'] == sqlIDs[neededId] & to_integer(df.iloc[row, 6]) >= to_integer(MostRecent)] This is the snippet that keeps getting me th

How to find the Unix timestamp of midnight time of the current day in the Eastern Daylight Time in Python

I am trying to write a Python code which will output the midnight time of the current day in Eastern Daylight Time. How can that be done?

What is the difference between running pyspark program with and without cluster?

I have a program that contain few lines of functions that uses pyspark (the rest is normal Python). The portion of my code that uses pyspark: X.to_csv(r'first.t

Finding datetime object in pandas df column

I have the following code, where I want to determine if a datetime object exists in a data frame. Here is the code: df_grid['Date'] = pd.to_datetime(df_grid['Da

Plotly Table does not show in Jupyter Lab in Python?

I try to plot table in Plotly in Python in Jupyter Lab. But my table in plotly does not show in Jupyter Lab, my code is as below: df = pd.read_csv('df.csv') fi

Remove or change background border line color

I have plotted an image with matplotlib and changed the background facecolor to gray, however there is this white border line around the background. I have trie

Python best practices and OOP with oracle

does any one have any material to recommend me on how to properly create a good CRUD code to handle python with oracle? I am doing some basic query/insert/updat

Match string from beginning to end of string

import re text = "A random\string here" test = re.findall('(?<=A ).+\s', text) I want to print out everything from the end of "A" (excluding the space) to

Why is C++ getline() non-blocking when program is called from python subprocess?

I have a C++ program that waits for some text input with getline(), and it works well from the command line. However, I would like to call it from Python - send

How can I redirect module imports with modern Python?

I am maintaining a python package in which I did some restructuring. Now, I want to support clients who still do from my_package.old_subpackage.foo import Foo i

Selenium Python - loop gets slower everytime

Im trying to automize downloading files, from a list of "cars" then save the file on my computer unzip it and rename it with the name of the car. Problem is, my

How can I add ordering for ManyToMany field?

I have two models: CustomUser and AgreementReglament At this moment relation between the models looks like this: class AgreementReglament(models.Model): nam

Python Grouped bar chart with multiple x-labels

I would like to plot a relatively simpler bar chart but struggling to plot using Matplotlib. Could I get some help please. I would like to prepare a chart as sh

How to stop a while loop after n iterations?

I'm learning python and I am trying to create the guess game with two levels of difficulty: easy (10 tries) and difficult (5 tries). My code works well, but I n