0

I have a list of dictionaries with values that I convert to a dataframe in pandas. I also convert the date-information (here measured in ms) to datetime and set a new index. The values are recorded every 5 seconds. When I want to resample them to 1 Minute I get the error message "DataError: No numeric types to aggregate" and I do not understand why. Here you see my code:

import pandas as pd

#convert list of dictionaries into a dataframe
dataframe = pd.DataFrame(data)

#convert the date-information (here measured in ms) to datetime
dataframe['timestamp'] = pd.to_datetime(dataframe['timestamp'], unit='ms')

#rearrange the columns
dataframe = dataframe.reindex(['timestamp','value'], axis=1)

#set the index to the column 'timestamp'
dataframe.set_index('timestamp', inplace=True)

#resample to a resolution of 1 minute
dataframe_minutes = dataframe.resample('1M').mean()

The problematic part is the last line dataframe_minutes = dataframe.resample('1M').mean(). Before that the dataframe looks like this:

dataframe before resampling

Do you have an idea, why I get this error because as far as I see it both columns have numeric values. I'd appreciate every comment.

PeterBe
  • 700
  • 1
  • 17
  • 37

0 Answers0