I know there are a lot of similar questions but I am pretty sure I have tried everything I found
Data:
TimeStamp
10:34:30
10:35:30
10:36:30
10:37:30
I have two different .csv files and I am trying to compare the times from the two in order determine further action.
I want to use .dt.hour
or .dt.min
to compare the times. Here's what I tried:
The type always remains str or float and the .dt.hour
or .dt.min
does not work
def csv_to_df(path, filename):
dateparse = lambda x: pd.datetime.strptime(x, '%H:%M:%S')
df = pd.read_csv(path + filename, skipinitialspace = True, parse_dates = True, date_parser = dateparse)
return df
I also tried using pd.to_datetime later for conversion. That didn't work either.
df_sr4500.TimeStamp=pd.to_datetime(df_sr4500.TimeStamp).dt.time
print(df_sr4500.TimeStamp[1].dt.hour)
ERROR: AttributeError: 'datetime.time' object has no attribute 'dt'