0

This is an error in the process of making a graph using a table.

First, I make a table t1.

t1=join_data.pivot_table(index='payment_ym', columns='registration_ym', values='quantity', aggfunc='sum', fill_value=0)

Then, in registrsation_ym, the dates were grouped into a larger range. enter image description here

t1['19.01-19.02']=t1['2019-01']+t1['2019-02']
...
t2=t1[['19.01-19.02','19.03-19.04','19.05-19.07' ]]

And i reset the t2's index.

So, t2 have two columns payment_ym,registration_ym. enter image description here

t2.plot(x='payment_ym', y=(['19.01-19.02', '19.03-19.04', '19.05-19.07']), kind='bar')

I want to make a bar chart like this one.

enter image description here

So, i try to use this code.

t2.plot(x='payment_ym', y=(['19.01-19.02', '19.03-19.04', '19.05-19.07']), kind='bar')

But it has an error. TypeError:string indices must be integers.

I don't know the reason. How can i resolve this?

bbkar
  • 1
  • 1
  • 1
    Post the full error message. As text, not image. – Ignatius Reilly Jan 26 '23 at 04:51
  • 1
    Where's `x='payment_ym'` coming from? `t2` has only columns `['19.01-19.02','19.03-19.04','19.05-19.07' ]`. It will probably work with `t1.plot(x= ...`. But it's impossible to say without a [mre] that allow us to reproduce your problem and try a solution. See [How to make good reproducible pandas examples](https://stackoverflow.com/questions/20109391/how-to-make-good-reproducible-pandas-examples). – Ignatius Reilly Jan 26 '23 at 04:56
  • Thank you for you advice. It's a first time to use this site. so i don't know that guidelines. I edit the question. – bbkar Jan 26 '23 at 06:33
  • You are still not showing the error. We need the full traceback. Also, I didn't get any error when I tried your code with a dummy dataframe. It would help a lot if you attach a sample of your data: `t2.head(4).to_dict()` will create a small copy-pastable dictionary that can be easily reconverted by us to a dataframe. Just verify before posting it that you can reproduce the error only with that sample. – Ignatius Reilly Jan 26 '23 at 15:27

0 Answers0