Category "pandas"

Transform a dataframe using pivot

I am trying to transform a dataframe using pivot. Since the column contains duplicate entries, i tried to add a count column following what's suggested here (Qu

text file rows into CSV column python

I've a question I've a text file containing data like this A 34 45 7789 3475768 443 67 8999 3343 656 8876 802 383358 873 36789 2374859 485994 86960 32838459 348

How do I print out the Phone number from a csv with padded 0 using pandas?

So I have a CSV file with the following content: Person,Phone One,08001111111 Two,08002222222 Three,08003333333 When I used the following code: import pandas a

Pandas' read_html not reading html tables

I am trying to see if I can use, and only use, Pandas' read_html function to scrape HTML tables from the following website: https://www.baseball-reference.com/t

Fill missing date and time in Python (pandas)

I have a large data set, a sample is given below. The data is recorded for 1 day with 5-min interval for 24 hours for 3214 unique ids. The time and date informa

How to delete older files and keep last day files for each month in python

I need to retain the backup file started on 31st april and ended next day May 1. backup timings differ for each folder, but the backup files are identical

Realise accumulated DataFrame from a column of Boolean values

Be the following python pandas DataFrame: ID Holidays visit_1 visit_2 visit_3 other 0 True 1 2 0 red 0 False 3 2 0 red 0 True 4 4 1 blue 1 False 2 0 0 red 1 Tr

How to calculate monthly changes in a time series using pandas dataframe

As I am new to Python I am probably asking for something basic for most of you. However, I have a df where 'Date' is the index, another column that is returning

invalid decimal literal when importing csv via pandas

not sure if something has changed within pandas but all of a sudden I am unable to import my .csv file using pd.read_csv due to the following error: PS C:\Users

Python pandas nlargest() not working properly with keep = 'all'

When I try to use the function below top3 = df1.nlargest(3, 'perChange', keep='all') Even if keep = 'all', the output is 92 3.828120 255 -0.673854 256

polars dataframe TypeError: must be real number, not str

so bascially i changed panda.frame to polars.frame for better speed in yolov5 but when i run the code, it works fine till some point (i dont exactly know when e

How to append row from itertuples to dataframe withouth losing the index in Python?

I have the following problem: I have a DataFrame df which looks like this: eqpid recpid queuetime trackintime trackouttime 3723

Using complex operations in query method of pandas

Let say I have below code, import pandas as pd dat = pd.DataFrame({'col1' : [1,2,3,4,5,6,7,8,9,10], 'col2' : ['A', 'X', 'D', 'Y', 'A', 'D', 'Y', 'X', 'D', 'A']}

How to delete empty spaces from pandas DataFrame rows until first populated field?

Lets say I imported a really messy data from a PFD and I´m cleaning it. I have something like this: Name Type Date other1 other2 other3 Name1 '' '' Type1

ModuleNotFoundError: No Module name 'pandasql'

I am trying to import pandasql. I am running the following code in a jupyter notebook running python: !pip install pandasql from pandasql import sqldf import

Pandas pivot table. Getting modes and relevant percentage

Here is the problem. While creating a pivot table in pandas data frame, I need to aggregate the column values for their modes as well as their relevant percenta

Create multiple boolean columns in pandas dataframe based on multiple conditions

I have a dataset, where authors are ranked by the order of authorship (1, 2, 3, etc). Authorid Author Article Articleid Rank 1 John article 1

Pandas: Writing Dataframe to an open Excel File

I am trying to call this python script from VBA in Excel with the click of a button, it will read the data but it will not write if the Excel file is open.. Eve

Pandas: Writing Dataframe to an open Excel File

I am trying to call this python script from VBA in Excel with the click of a button, it will read the data but it will not write if the Excel file is open.. Eve

How to keep columns header on excel without change after export data to excel file?

I work on sql server 2017 I run script depend on python language v 3.10 . I need to export data to excel fileStudentExport.xlsx already exist, and keep header w