0

I have the following dataframe:

enter image description here

When I plot this, I get the following:

Plot

But what I want is that the values of all the columns should be appended to one single columns so that I can obtain just one single line. I mean, there should be no column number 4,5,6,7. Just one single column with the values of all these. My Problem:

  1. Not able to convert Index from month names to 0,1,2,3,. I have used Set_Index but it didnt work
  2. Used Append command with drop index but didn't get any results.

I m just one day old in learning pandas. Kindly give me lead.

Snoke
  • 75
  • 7

1 Answers1

3

Try:

single_column_frame = pd.concat([df[col] for col in df.columns])

If you want to create a single column and get rid of month names:

df_new = df.melt()['value'].to_frame()

Or you can do:

single_column_frame = single_column_frame.reset_index().drop(columns=['index'])

You can also do:

single_column_frame = df.stack().reset_index().loc[:,0]