I am really new of Pandas and I have a problem how to calculate the average value of a set of time.
I have a csv file with columns: Date, Time, Outside temperature
I imported and modify it as:
df = pd.read_csv("./file.csv", parse_dates=[0], dayfirst=True)
df["Date"] = pd.to_datetime(df["Date"])
df["Time"] = pd.to_datetime(df["Time"]).dt.time
I prefer to have the date and time separate in two different columns and not use them as index.
I already extracted the part I need and obtaining something like this:
Date Time Outside Temperature
4343 2006-06-30 13:00:00 15.9
4344 2006-06-30 13:10:00 15.9
4345 2006-06-30 13:20:00 15.9
4346 2006-06-30 13:30:00 15.9
4347 2006-06-30 13:40:00 15.9
as you can see at same temperature I have different time, I would like to have the average value of the time, something like: 13:22:34
How can I do it?
I checked other questions as: Average time for datetime list, I tried several way to access to the time, for example:
print(tempdf["Time"].dt.hour)
but I obtain the error:
AttributeError: Can only use .dt accessor with datetimelike values
I think I make a mistake in the conversion to timestamp.
Do you have any suggestion?
I am using python3.5 and pandas 0.20.2
Thanks a lot
Ciccio
Edit:
The original csv file for the time has the format hh:mm without the seconds.