Skip to content

Tag: dataframe

Pandas .isin on column entries containing lists

I am trying to filter a dataframe using the isin() function by passing in a list and comparing with a dataframe column that also contains lists. This is an extension of the question below: How to implement ‘in’ and ‘not in’ for Pandas dataframe For example, instead of having one countr…

Python: concatenate pandas multiindex

I need to generate a pd.DataFrame with columns being composed by a list and a Multiindex object, and I need to do it before filling the final dataframe with data. Say the columns are [‘one’, ‘two’] and the multiindex obtained from from_product: I would like to get a list of columns whi…

Fast way to cyclically wrap values in pandas dataframe

In words: I have a data frame that consists of values over a day, for multiple days per Userid. I’d like to shift all of certain people’s data by 1 period, so that the first value in their first column is a nan, and then everything is cyclically offset, with the last value truncated or lost to spa…

count multiple value in dataframe

I have a dataframe that shows answers of a multiple choice question of 5 students: And I want to count how many times does a choice been selected. For example, the final answer should be So is there a quick way to get the solution using python? Besides, I am using the data from the dataframe for visualization…