Category "pandas"

Sum of different slices rows and column

I have pandas DataFrame df and three arrays columns_list, lower_boarder and upper_boarder all have the same shape. I want to find array with shape as input arra

FastAPI - Dataframe updated change lost between route

I'm trying to make a simple FastAPI api. Let's suppose these routes: The POST Route @api.post('/user', name='Get list of users') def get_user(user: User):

Pandas cannot open an Excel (.xlsx) file

Please see my code below: import pandas df = pandas.read_excel('cat.xlsx') After running that, it gives me the following error: Traceback (most recent call las

Count occurrences within a specific range

I have a data frame that looks like this: Tag 0 skip_1 1 run 2 skip_1 3 run 4 skip_1 5

TypeError: This COM object can not automate the makepy process - please run makepy manually for this object

What this kind of error? Traceback error C:\Users\DELL\PycharmProjects\MyNew\venv\Scripts\python.exe C:/Users/DELL/PycharmProjects/MyNew/agaaaaain.py Traceba

Unable to resolve pandas encoding error by changing encoding

I'm having trouble resolving an encoding error when reading a csv file using the pandas library. import pandas as pd filepath = "D:\Datasets\2019HighwayBridgeIn

Splitting and grouping pandas into intervals and calculating mean based on different column

I have a well-known Titanic dataset and I am trying to find the survival probability of a person, based on their age and sex. The input I am given is the number

convert numpy array of float64 values to datetime64 with python and pandas

If I have a NumPy array of float64 values. I know these values represent dates in format of datetime64[ns]. I try to convert them with pandas. But I get an Valu

Parse txt file in Pandas

I have the table in file and it looks like that: +-------------+-----------------+---------------+---------------+--------------+ |number |name

Pandas Value Error: Cannot set item on a Categorical with a new category, set the categories first

I've been looking for other similar issues on this ValueError, but none of them has the same code as I have. So here it is. As I am still very new at this, I am

How to compare just the date or just date time ignoring seconds in a Python Pandas dataframe column of mixed data types?

In a pandas dataframe, I have a column of mixed data types, such as text, integers and datetimes. I need to find columns where datetimes match: (1) exact values

ValueError with pandas apply function returning output of variable shape

I have a pandas dataframe with three columns structured like this: Sample Start End <string> <int> <int> The values in "Start" and "End

How to find the number of seconds elapsed from the start of the day in pandas dataframe

I have a pandas dataframe df in which I have a column named time_column which consists of timestamp objects. I want to calculate the number of seconds elapsed f

How do I use regex to remove substring before a pipe in pandas dataframe?

In cna pandas dataframe, for all values of Hugo_symbol column, if there is a pipe (|) followed by "ENSG*", remove everything before the pipe. My code: import re

Python calculate increment rows till a condition

How to obtain the below result. Sample Data with Output Time To default is the column which is to be calculated. We need to get the increment number as Time to

Pandas to_excel( ) output float point is not right

I have some a weird situation trying to get the output in to_excel pandas function. I tried to read a xlsx excel file with the number "21631706.9893399", but wh

Pandas Group by index Hour and keeping observation for each hour

I have a pandas dataframe containing one column and a datetime index, i need to group the data by hour and keep each obsevation (record) for each of the grouped

ParseError: Error tokenizing data. C error: Buffer overflow caught - possible malformed input file. (read_csv)

I cannot use read_csv method of pandas properly on kaggle. Error that I get is: ParseError: Error tokenizing data. C error: Buffer overflow caught - possible ma

Restricting multiple-indexes/header to one column using pandas

Following code gives me header= Rice in every column. I wan to restrict it to only column 0 or the first column and put all other as blank. Basically I want to

Failure importing openpyxl in Spyder 5.1.5

So I am trying to open a.xlsc file in Spyder using pandas. After importing pandas as pd, when using pd.read_excel() command in the console, it showed the error: