Skip to content

Tag: pandas

Pandas: automatically reorder columns based on condition

I have this table, with index columns represented by week number: I want to reorganize columns order to obtain this: Weeks 1 & 2 are for 2022, weeks 45 to 52 are for 2021, so I want reorganize table to have weeks 1 & 2 after week 52. I did this code, but I would have an automatic solution: For

Pandas – Groupby and Standardize

I have tried to tackle this for quite some time, but haven’t been able to get a pythonic way around it by using the built-in groupby and transform methods from pandas. The goal is to group the data by columns ex_date and id, then within the groups identified, standardize the column called ref_value_1 ag…