1

I have two DataFrame north and south. Each has same rows and columns. I would like to plot the speed columns of both DataFrames in one figure as bar chart. I am trying this:

ax = south['speed'].plot(kind='bar', color='gray')
north['speed'].plot(kind = 'bar', color='red', ax=ax)
plt.show()

But it plots only the last dataframe , i.e. only the north DataFrame. Can you help me?

1 Answer 1

1

1) If you would like to plot just 'speed' column, you have to concatenate dataframes like:

df = pd.concat([north, south]) 

or

df = north.append(south)

2) If you would like to compare 'speed' column of both dataframes, you have to join dataframes along axis=1 like:

df = pd.concat([north, south], axis=1, ignore_index=True)

and the call plot method of df.

For more info: https://pandas.pydata.org/pandas-docs/stable/merging.html

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

2 Comments

Thank you for the perfect answer. But, still have one question. I would like to compare the speed and the index of the north and south are dateIndex. If the rows are same but the value of index are not then, then what I can do?
I can not figure out short answer for this problem. May be make group by speed values and then compare data in a group?

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.