Python: Excel - Bar chart plot

jamescooper

Well-known Member
Joined
Sep 8, 2014
Messages
887
import pandas as pd
import matplotlib.pyplot as plt
filtered_df = df[df['Hotel Name'] == 'Clayton Hotel']
today_format = datetime.strptime(datetime.today().strftime('%d/%m/%Y'), "%d/%m/%Y")
filtered_df = df[df['Date Captured'] == today_format]
df.plot(x="Check-In", y=["'Current price'"], kind="bar")

Any ideas what I am doing wrong here?

Many thanks.
 
What is the error that you received?

Regards,
GB
 
Upvote 0
Well, if you give me the real error I can help you, if not I can't.

Regards,
GB
 
Upvote 0
You didn't import datetime.
You have single and double quotes on the last line.
 
Upvote 0
That is a real error code.
Yes, that is excel error, I meant it in real PY output. I believe the error is because "DataFrame object" DF has to be defined before it is used.
 
Upvote 0
Thanks, have added datetime import datetime and take the '' from last row.

Any other ideas? The dataframe is defined earlier on in the workbook.

import pandas as pd
from datetime import datetime
import matplotlib.pyplot as plt
filtered_df = df[df['Hotel Name'] == 'Clayton Hotel']
filtered_df = df[df['Date Captured'] == today_format]
today_format = datetime.strptime(datetime.today().strftime('%d/%m/%Y'), "%d/%m/%Y")
df.plot(x="Check-In", y=["Current price"], kind="bar")

I'm now getting #Timeout!
 
Upvote 0
Thanks, have added datetime import datetime and take the '' from last row.

Any other ideas? The dataframe is defined earlier on in the workbook.

import pandas as pd
from datetime import datetime
import matplotlib.pyplot as plt
filtered_df = df[df['Hotel Name'] == 'Clayton Hotel']
filtered_df = df[df['Date Captured'] == today_format]
today_format = datetime.strptime(datetime.today().strftime('%d/%m/%Y'), "%d/%m/%Y")
df.plot(x="Check-In", y=["Current price"], kind="bar")

I'm now getting #Timeout!
Try to run "Reset Runtime" from the formulas menu (PY).
Or change the runtime, please look at the attached screenshot.
Regards,
GB
 

Attachments

  • pyto.png
    pyto.png
    31.6 KB · Views: 6
Upvote 0

Forum statistics

Threads
1,226,831
Messages
6,193,206
Members
453,779
Latest member
C_Rules

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top