multi-level

How to add computed columns in a multi-level column dataframe

How to add computed columns in a multi-level column dataframe Question: I have a multi-level column dataframe on the lines of one below: How can I add columns ‘Sales’ = ‘Qty’ * ‘Price’ one each for each ‘Year’? The input dataframe in dictionary format: {(‘Qty’, 2001): [50, 50], (‘Qty’, 2002): [100, 10], (‘Qty’, 2003): [200, …

Total answers: 2

Random Sampling a Multi-level column

Random Sampling a Multi-level column Question: level column DataFrame that looks like this: df Solid Liquid Gas pen paper pipe water juice milk oxygen nitrogen helium 5 2 1 4 3 1 7 8 10 5 2 1 4 3 1 7 8 10 5 2 1 4 3 1 7 8 10 4 4 …

Total answers: 2

How to simply add a column level to a pandas dataframe

How to simply add a column level to a pandas dataframe Question: let say I have a dataframe that looks like this: df = pd.DataFrame(index=list(‘abcde’), data={‘A’: range(5), ‘B’: range(5)}) df Out[92]: A B a 0 0 b 1 1 c 2 2 d 3 3 e 4 4 Asumming that this dataframe already exist, how …

Total answers: 7