Skip to content

Tag: dataframe

Reverse a get_dummies encoding in pandas

Column names are: ID,1,2,3,4,5,6,7,8,9. The col values are either 0 or 1 My dataframe looks like this: I want the column names in front of the ID where the value in a row is 1. The Dataframe i want should look like this: Please help me in this, Thanks in advance Answer set_index + stack, stack will dropna by …

Python Dataframes: Describing a single column

Is there a way I can apply df.describe() to just an isolated column in a DataFrame. For example if I have several columns and I use df.describe() – it returns and describes all the columns. From research, I understand I can add the following: “A list-like of dtypes : Limits the results to the prov…

Sort a pandas dataframe series by month name

I have a Series object that has: Problem statement: I want to make it appear by month and compute the mean price for each month and present it with a sorted manner by month. Desired Output: I thought of making a list and passing it in a sort function: but the sort_values doesn’t support that for series.…