Category "dataframe"

Get index and column with multiple headers and index_col in Pandas DataFrame

I have a dataframe with multiple headers and column indexes, and would like to retrieve the list of entries that are non-zero. The dataframe is constructed from

How to edit/ sort a non-column column in Python?

I wrote the script below, and I'm 98% content with the output. However, the unorganized manner/ disorder of the 'Approved' field bugs me. As you can see, I trie

How to fix ParserError: year 0 is out of range: 0000-00-00 with Python Pandas to_datetime method

I am trying to convert a column "travel_start" to a datetime object. Dashboard["travel_start"] = pd.to_datetime(Dashboard["travel_start"]) But I get the fol

How do to speed up ordinary dataframe loop in python? vectorisation? multiprocess?

I have a simple piece of code. Essentially, I want to speed up my loop that creates a dataframe using dataframes. I haven't found an example and would appreciat

rows wise correlation between two Dataframe which have unequal columns

I have two Dataframes, (Dataset1=200rows, 34 column)(Dataset2=200rows, 22 column). I want rows wise correlation between both datasets. how can I perform this. I

get the index of search item in a dataframe

I have a dataframe which contain a column combine 0 (43,FR,html5 full skinz html5) 1 (43,FR,mobile m-skinz2) 2 (43,FR,mobile m-skinz2 plus) 3

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

How to create columns from anothers columns?

I want to built a dataframe like df2 from df1, looking always for the name of the column where the value is closet to 0: Where clossets_1 - closer value to 0 of

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

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

Error with a python string to dateconversion using Pandas

I'm struggling to change the format of the dates of my dataframe. I get the following error: ValueError: to assemble mappings requires at least that [year, mont

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

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

How do I create a list containing new data frames from an existing data frame?

I have a csv file containing 5 columns, 225 rows containing my data. The columns pertain to the experiments' Subject_ID, treatment (9 types), replicate(5), time

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

Use of Replace() in Python Dataframe for Multiple Columns but same value

Query: I need to replace the 1 old value with the 1 new value for a bunch of columns (not all columns) in a dataframe. The question is about the syntax to be us

Transforming data using Python Pandas (or M) in Power Query for PowerBi

I have some data about projects I would like to transform in a way that makes it easier to analyse with PowerBi. The data looks like this: Project Number Proje

creating new column in dataframe with the values from another column in the same dataframe [duplicate]

As a scientific researcher I am a beginner in Python. I am trying to make a new column in the following dataframe: