Skip to content

Tag: pandas

xlswriter formatting a range

In xlswriter, once a format is defined, how can you apply it to a range and not to the whole column or the whole row? for example: this gets applied it to the whole “B” column, but how can this “perc_fmt” applied to a range, for example, if I do: it says: Answer Actually I found a work…

Groupby and lag all columns of a dataframe?

I want to lag every column in a dataframe, by group. I have a frame like this: which looks like and I want it to look like this: This question manages the result for a single column, but I have an arbitrary number of columns, and I want to lag all of them. I can use groupby and apply, but

Pandas dataframe from nested dictionary

My dictionary looks like this: I want to get a dataframe that looks like this: I tried calling pandas.from_dict(), but it did not give me the desired result. So, what is the most elegant, practical way to achieve this? EDIT: In reality, my dictionary is of depth 4, so I’d like to see a solution for that…