Questions tagged [pandas-resample]

Relating to up- or down-sampling time series data in the Python package pandas, specifically the methods pandas.DataFrame.resample() and pandas.Series.resample().

314 questions
0
votes
2 answers

Pandas resample and aggregate with condition

I have a DataFrame which have a column with statuses like this: datetime | session | try | status 2020-09-17 10:00:01 | '1a' | '1a_1' | 'success' 2020-09-17 10:00:02 | '2a' | '2a_1'…
Pruntoff
  • 615
  • 3
  • 8
  • 18
0
votes
3 answers

Resample within time frame in Python

I would like to resample df by creating monthly data for all columns and filling in missing values with 0, within the time frame of say 2019-01-01 to 2019-12-31. df: ITEM_ID Date Value YearMonth 0 101002 2019-03-31 1.0 2019-03 1 …
nilsinelabore
  • 4,143
  • 17
  • 65
  • 122
0
votes
2 answers

Python - Best way to Average a Resample in Pandas

I have a dataframe. Here is a very limited example. userID scoreMetric timeStamp 123 5 2020-05-16 22:03:19 313 1 2020-05-16 22:03:20 123 4 2020-05-16 22:13:20 313 2 …
Jibril
  • 967
  • 2
  • 11
  • 29
0
votes
0 answers

how to resample in pandas data frame for month wise according to Datetimeindex

furniture = furniture.groupby('Order Date')['Sales'].sum().reset_index() print(furniture.head()) Output: Order Date Sales 0 2014-01-06 2573.820 1 2014-01-07 76.728 2 2014-01-10 51.940 3 2014-01-11 9.940 4 2014-01-13 879.939 when…
user11150618
0
votes
1 answer

Monthly to Daily values

I have a monthly value which I would like to change to daily data; Date Ireland UK France 01/09/2020 42 87 84 01/10/2020 85 45 65 01/11/2020 45 42 89 01/12/2020 45 15 41 01/01/2020 34 …
spcol
  • 437
  • 4
  • 15
0
votes
0 answers

How to resample tick data to get ohlc and volume values

I have a dataframe like this crdf = pd.DataFrame(Maindf.loc[Maindf['Symbol'] == 'ICICIBANK']).set_index(['TimeStamp']) crdf.index = pd.to_datetime(crdf.index) crdf['Ltp'] = crdf['Ltp'].astype('float64') crdf['Volume'] =…
0
votes
1 answer

Python Datetime resample results suddenly in NaN Values

I have tried to resample my values to hour. However, since I have changed the format of the date in csv file because of automatic swapping of months and days with low numbers (2003-04-01 is suddenly 2003-01-04). Now the date format is fine (when…
NadineH33
  • 1
  • 1
0
votes
1 answer

Can I dynamically choose the method applied on a pandas Resampler object?

I am trying to create a function which resamples time series data in pandas. I would like to have the option to specify the type of aggregation that occurs depending on what type of data I am sending through (i.e. for some data, taking the sum of…
Tom
  • 8,310
  • 2
  • 16
  • 36
0
votes
1 answer

Resample time series - Python

I'm trying to resample a time series. I just can't seem to get it working. Based off other examples I don't understand why this isn't returning a time series: df1 = pd.DataFrame({'Time': ['2019-08-02 09:50:10.100','2019-08-02…
jonboy
  • 415
  • 4
  • 14
  • 45
0
votes
0 answers

pandas weighted average using .resample() and .groupby() problems

I have problems when trying to calculate the volume weighted average price using .resample() method and .apply(). Here is the setting. I have a dataframe called All with the following info: All.head() price volume…
friend1
  • 11
  • 1
0
votes
2 answers

Add up rows according to year

My dataframe look like this: Dividends Stock Splits Date 2014-08-13 0.28 0.0 2015-04-27 0.30 0.0 2015-07-31 0.30 0.0 2016-05-05 0.30 …
Lawrence How
  • 41
  • 1
  • 8
0
votes
0 answers

Resample Monthly to Weekly does not start the week at monday?

I have a dataframe df: year | month | A 2020 | 1 | 4 2020 | 2 | 4 2020 | 3 | 6 2020 | 4 | 5 2020 | 5 | 5 I want to resample that to weekly and get the week of the year as a new column. Each week of a month should get an equal…
Vega
  • 2,661
  • 5
  • 24
  • 49
0
votes
1 answer

Pandas resample is jumbling date order

I'm trying to resample some tick data I have into 1 minute blocks. The code appears to work fine but when I look into the resulting dataframe it is changing the order of the dates incorrectly. Below is what it looks like pre resample: …
0
votes
3 answers

Pandas Series Resample

I have the following pandas series: dummy_array = pd.Series(np.array(range(-10, 11)), index=(np.array(range(0, 21))/10)) This yield the following array: 0.0 -10 0.1 -9 0.2 -8 0.3 -7 0.4 -6 0.5 -5 0.6 -4 0.7 -3 0.8 …
Joao Antunes
  • 193
  • 1
  • 12
0
votes
1 answer

Pandas resample on specific time range everyday

I've written below code on Python3 for resampling timeseries data. My requirement is to resample data only between 9:00 AM to 4:00 PM for each day. However I can't do the resample operation separately by grouping the complete data using "group by…
BARUN
  • 139
  • 12
1 2 3
20
21