0

This seems very simple and I am not sure why it's not working. It works fine when I use a stacked bar chart, but when I use a line chart the formatting is not correct (or something else is not working?). For example, the stacked barchart looks like enter image description here

Very simple logic to create the above chart:

pivot_df = base_df.pivot(index='date', columns='column10', values='values')
pivot_df1 = pivot_df.fillna(0)
pivot_df1 = pivot_df1.astype(float)
pivot_df1 = pivot_df1.plot.bar(stacked=True, figsize=(10,7))

Now I am trying to create a line chart using the same base dataset (so same dates) but slightly different columns/values. I filter the dataset on one condition and remove a few columns (not sure if this is causing the issue?).

base_df1 = base_df[((base_df['filter_column'] == 'this'))]
base_df1 = base_df1[['date', 'column2', 'column3', 'column4']]
base_df1 = base_df1.fillna(0)
base_df1 = base_df1.astype(float) 
base_df1_piv = base_df1.pivot_table(index='date',columns='column2', values = 'column3')
base_df1_piv.plot.line()

x axis date issue

I feel like I am missing something very obvious? Any help is appreciated.

cexcelc
  • 57
  • 2
  • 8
  • It is much easier to help you if you can include sample data in your dataframe for `base_df`. Please see: https://stackoverflow.com/questions/20109391/how-to-make-good-reproducible-pandas-examples – David Erickson Oct 31 '20 at 00:57
  • I could venture a guess, but without a minimum reproducible example it's hard to know if the guess is right. – B. Bogart Oct 31 '20 at 00:59

0 Answers0