0

I don't know why the resample function doesn't work properly.

I'm trying to resample with the simplest example but the function does not overwrite the original dataframe.

import pandas as pd

index = pd.date_range('1/1/2019', periods=8, freq='T')
series = pd.Series(range(8), index=index)
series.resample('3T').sum()

printing the resulting series gives me:

print(series)
>2019-01-01 00:00:00    0
>2019-01-01 00:01:00    1
>2019-01-01 00:02:00    2
>2019-01-01 00:03:00    3
>2019-01-01 00:04:00    4
>2019-01-01 00:05:00    5
>2019-01-01 00:06:00    6
>2019-01-01 00:07:00    7
>Freq: T, dtype: int64

In my use case I wanted to upscale a dataframe but that also didn't work.

  • What gave you the impression it was supposed to be overwritten? You need to assign the result back: `result = your_df.some_operation()` unless you're using `inplace=True` (which you should not) – cs95 Dec 16 '20 at 23:54
  • I was following the examples where they do not assign the return of the function: https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.resample.html#pandas.DataFrame.resample – horstseehofer Dec 17 '20 at 06:30
  • They don't assign it because the output is only for demo purposes – cs95 Dec 17 '20 at 10:11

0 Answers0