Skip to content

Tag: pandas

Pandas groupby counting values > 0

I have a pandas df of the following format I am looking to transform it such that I land up with the below result Essentially for “HIGH_COUNT” and “LOW_COUNT” I want to count the number of occurrences that column was greater than 0, grouped by “MATERIAL”. I have tried to do…

Pandas: Find difference in rows with same index in any column

Sample dataframe: If you see here, the rows with common index have atleast one difference amongst them. For ex: Rows with index 0, have difference in column_name. Rows with index 5, have difference in max_length. Rows with index 6, have differences in both data_type and default. Rows with index 8, have differ…

Pandas apply/lambda on multiple columns

I have a simple script transforming data in a dataframe: The above seems to work fine. I have tried rewriting the last two lines to: However, this fails and gives a value error: I am trying to understand why it can’t be used in the above way. My pad_value function seems clunky – I wonder if there …