I got this dataframe df,
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
table = {'Count_Product': pd.Series([1,2,3]), 'Count_Transaction': pd.Series([1,1,2])}
df = pd.DataFrame(table)
df
Count_Product Count_Transaction
0 1 1
1 2 1
2 3 2
And I want to do a simple bar plot where the x axis is Count_Product and y axis is Count_Transaction. I used the following code to generate,
%matplotlib inline
ax = df['Count_Product'].plot(kind='bar', figsize=(5,5), color='blue')
ax.set_ylabel("Count_Transaction")
ax.set_xlabel("Count_Product")
patches, labels = ax.get_legend_handles_labels()
ax.legend(patches, labels, loc='best')
And the graph output is,
My problem is the x-axis is showing 0,1,2 instead of 1,2,3 from the Count_Product column. It looks like it is taking the 1st column as the x-axis automatically.
Does anyone know how can I code the correct column to use the Count_Product column as the x-axis?
Thanks, Lobbie

