i want to convert that dataframe into this dataframe and plot a matplotlib graph using date along x axis changed dataframe
-
Isn't this question a dupe of your previous question: stackoverflow.com/questions/40161665/…?EdChum– EdChum2016-10-21 08:05:45 +00:00Commented 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.Manaf Mh– Manaf Mh2016-10-21 16:10:38 +00:00Commented Oct 21, 2016 at 16:10
Add a comment
|
1 Answer
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:
3 Comments
Manaf Mh
how can i convert the dataframe into the 'changed dataframe'. I tried transpose function.but then i cant able to plot that dataframe.
Kennet Celeste
@ManafMh you may also "Accept" an answer when it fully answers your question
Kennet Celeste
@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.
