0

i want to convert that dataframe into this dataframe and plot a matplotlib graph using date along x axis changed dataframe

2
  • Isn't this question a dupe of your previous question: stackoverflow.com/questions/40161665/…? Commented Oct 21, 2016 at 8:05
  • how can i convert the dataframe into the 'changed dataframe'. I tried transpose function.but then i cant able to plot that dataframe. Commented Oct 21, 2016 at 16:10

1 Answer 1

1

Use df.T.plot(kind='bar'):

import pandas as pd
import matplotlib.pyplot as plt

df = pd.DataFrame.from_csv('./housing_price_index_2010-11_100.csv')

df.T.plot(kind='bar')
plt.show()

you can also assign the transpose to a new variable and plot that (what you asked in the comment):

import pandas as pd
import matplotlib.pyplot as plt

df = pd.DataFrame.from_csv('./housing_price_index_2010-11_100.csv')

df_transposed = df.T
df_transposed.plot(kind='bar')
plt.show()

both result the same:

enter image description here

Sign up to request clarification or add additional context in comments.

3 Comments

how can i convert the dataframe into the 'changed dataframe'. I tried transpose function.but then i cant able to plot that dataframe.
@ManafMh you may also "Accept" an answer when it fully answers your question
@ManafMh no I mean if the answer addresses your question accept it by clicking on the check mark like this so that others notice it will work in the first look.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.