Python code for Excel

jamescooper

Well-known Member
Joined
Sep 8, 2014
Messages
887
Got my data loaded through a connection, a sample of the data is shown below.

In Python for Excel I have successfully used:

df['Current price'].mean() To determine the mean

How do I now determine the mean of Check-In dates?

This is what I have tried without success.

df.groupby(["Check-In"]).['Current price'].mean()

Any help appreciated.


Source.NameDate CapturedHotel NameCheck-InCheck-OutPriceratingOriginal priceCurrent price
2025-01-22.xlsx22/01/2025Radisson Blu Hotel, Cardiff22/01/202523/01/2025Original price £104. Current price £94.Scored 7.9 Original price £10494
2025-01-22.xlsx22/01/2025Park Inn by Radisson Cardiff City Centre22/01/202523/01/2025Price £79Scored 7.8 None79
2025-01-22.xlsx22/01/2025Hotel Indigo - Cardiff, an IHG Hotel22/01/202523/01/2025Price £134Scored 8.9 None134
2025-01-22.xlsx22/01/2025Clayton Hotel Cardiff22/01/202523/01/2025Original price £139. Current price £125.Scored 8.4 Original price £139125
2025-01-22.xlsx22/01/2025Holiday Inn Cardiff City, an IHG Hotel22/01/202523/01/2025Price £94Scored 8.1 None94
 
Try:
Excel Formula:
df.groupby('Check-In')['Current price'].mean()
 
Last edited:
Upvote 0
Hello,
From a Python/Pandas "point of view", your proposition was absolutely correct. There is no difference between single quote and double ones to delimit strings. I think the latter are forbidden/buggy? in Python for Excel as they might interfere with Excel double-quote string delimiter.
 
Upvote 0
Is there any Internet content you can recommend for learning these basics for Python formulas in Excel?
Python in Excel is simply Python.
There are many resources to learn Python.
 
Upvote 0

Forum statistics

Threads
1,226,834
Messages
6,193,222
Members
453,781
Latest member
Buzby

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