Skip to content

Tag: pandas

Pandas fill missing dates and values simultaneously for each group

I have a dataframe (mydf) with dates for each group in monthly frequency like below: I want to fill the dt for each group till the Maximum date within the date column starting from the date of Id while simultaneously filling in 0 for the Sales column. So each group starts at their own start date but ends at t…

Pandas create flag if any condition fails

I have a huge pandas dataframe (actually has 5M rows): My requirement is to create a flag with value as 1 if any of the close dates cls1..5 is < the corresponding open date opn1..5 Example output: for id==2, cls5 < opn5 I want to avoid a loop and run it as fast as possible. There are ~5M rows in