Skip to content

Tag: python

Pandas multiIndex slicing by aggregate

I have a pandas Series (S) that has an index like: I have a conditional function that returns a lower dimensional index. What I am doing is performing something like S.groupby(level=(0,1)).median() > 1 This returns a Series with Index like so: How do I slice the original Series with the lower dimensional i…

Why Pandas custs the zero in the first position?

I load data to dataframe: Dataframe has column with value: 00590 After load dataframe I got this as 590. I have tried dtype=’object’. Does not help me. Answer Have you tried using str instead of object? if you use str (string) it maintains the zeros at the beginning. It could be good to specify th…