Skip to content

Tag: pandas

Pandas groupby collapse 1st rows of group

I have a system that lets me export data in a table of this format: ​ where there are many columns like ‘data’ and they can have any values that don’t necessarily follow a pattern. I need to get the data into this format: I’ve tried reading the documentation on gropuby and searching si…

Calculate delta in dictionary of dictionary

I have a dictionary of dictionaries which hold list of tuples like this: I would like to calculate the delta of the third items (which their first two items are identical) in each tuple inside of the dictionaries, between each week (e.g., week1 and week2,.. week19 and week20)and put them as new dictionaries i…

CSV data preprocess

I have a .csv file like this format Then I want to convert it to How can I do it with python pandas Thank you Answer If you load it then you will have DataFrame like Set multi-index usinig year and month Reshape it using stack() You can add name to column with day Reset index to get normal columns