Questions tagged [pandas-timeindex]

questions related to pandas time series functions and methods

pandas contains extensive capabilities and features for working with time series data for all domains. Using the NumPy datetime64 and timedelta64 dtypes, pandas has consolidated a large number of features from other Python libraries like scikits.timeseries as well as created a tremendous amount of new functionality for manipulating time series data.

Read more here.

21 questions
4
votes
1 answer

Pandas: cut date column into period date groups/bins

I have a dataframe as below: df = pd.DataFrame({'Id': ['abs1', 'abs2', 'abs3', 'plo2', '201805', '201806', '202011', 'pctx1'], 'Date': ['2021-06-15', '2021-06-13', '2021-06-07', '2021-05-30', …
XaviorL
  • 373
  • 1
  • 13
3
votes
1 answer

Pandas rolling time window fails on count of string - why?

Trying to use pandas rolling with a timeindex and the count() method, getting an error, what am I missing here? here is an example: d = {'vv': {pd.Timestamp('2020-01-13 08:22:00', freq='T'): 'aa', pd.Timestamp('2020-01-13 08:23:00', freq='T'):…
Ezer K
  • 3,637
  • 3
  • 18
  • 34
1
vote
1 answer

pandas how to get mean value of datetime timestamp with some conditions?

I have a df ,you can have it by copy and run the following code: import pandas as pd from io import StringIO df = """ b_id duration1 duration2 user 366 NaN 38…
William
  • 3,724
  • 9
  • 43
  • 76
1
vote
1 answer

Pandas GroupBy time idxmax w/ empty groups throws exception

I have a list of several million events in time stored in a data frame df. df.head() gives output: rel_temp timestamp 2016-04-04 10:41:07.663457 0.02 2016-04-04 11:05:44.382078 -0.05 2016-04-04…
chazzmoney
  • 221
  • 2
  • 9
1
vote
2 answers

To find a chosen date between date range of two columns

please help me please to find out the way how to check if "chosen_date" is in range between columns "date1" and "date2". from datetime import datetime chosen_date = datetime.today().strftime("%Y-%m-%d") date1 date2 2000-06-02 …
1
vote
1 answer

How to select a range of consecutive dates of a dataframe with many users in pandas

I have a dataframe with 19M rows of different customers (~10K customers) and for their daily consumption over different date ranges. I have resampled this data into weekly consumption and the resulted dataframe is 2M rows. I want to know the ranges…
1
vote
2 answers

Why can't I select whole days from intra-day time series?

I have basic financial OHLCV data. Datetime Open Volume date 0 2021-08-25 09:30:00-04:00 149.699997 3524920 2021-08-25 1 2021-08-25 09:35:00-04:00 149.699997 1424746 2021-08-25 2 2021-08-25…
Borut Flis
  • 15,715
  • 30
  • 92
  • 119
1
vote
1 answer

Finding the midpoint between values in a pandas datetime column and making a start and end time period column based on the midpoint

Here is my code set up: import pandas as pd df = {'Datetime': ['2020-12-01 00:00:00', '2020-12-01 01:00:00','2020-12-01 02:00:00', '2020-12-01 03:00:00', '2020-12-01 04:00:00' , '2020-12-01 05:00:00' , …
0
votes
1 answer

Pandas time series index attribute error when using TsTables & PyTables in creating a table class

I am trying to create a table structure through tb.IsDescription class, then create a .h5 file and populate it with a Pandas Dataframe with Datetime index, using TsTables package. I have already tested the Dataframe and the date time Indexing and…
0
votes
1 answer

How to count number of values in column based on one timestamp value python and add the count to new column

DateTime car 2015-04-16 11:57:36 bmw 2015-04-17 15:32:14 bmw 2015-04-17 19:13:43 audi 2015-04-17 05:12:16 porche 2015-04-17 13:43:31 toyota 2015-04-15 07:02:20 ferrari In this dataframe df I need to…
0
votes
1 answer

How to generate monthly period index with annual frequency?

How would generate in the most concise way a monthly period index that is observed only every 12 months? I came up with the following solution pd.period_range(start=pd.Period('1975-07'), end=pd.Period('1985-07'), …
0
votes
0 answers

Grouping time-series by some custom datetime range?

I have a simple OHLCV time-series. I obtain it from yahoo finance. Open High Adj Close Volume Datetime 2021-11-27…
Borut Flis
  • 15,715
  • 30
  • 92
  • 119
0
votes
1 answer

Round all index to 30 min in Pandas datetimeindex

I know about round, ceil, floor functions. df.index.round("30min") This rounds to the nearest 30 minute interval. What I want is that each is rounded to 30 minutes. In the case of .round 10:15 will be rounded to 10:30 and 10:45 to 11:00. I would…
Borut Flis
  • 15,715
  • 30
  • 92
  • 119
0
votes
2 answers

How to resample intra-day intervals and use .idxmax()?

I am using data from yfinance which returns a pandas Data-Frame. Volume Datetime 2021-09-13 09:30:00-04:00 951104 2021-09-13 09:35:00-04:00 408357 2021-09-13 09:40:00-04:00 …
Borut Flis
  • 15,715
  • 30
  • 92
  • 119
0
votes
1 answer

Best way to filter out data from specific month in pandas

I have financial data: Open High ... Adj Close Volume Date ... 2016-11-17 60.410000 60.950001 ... 56.484898 32132700 2016-11-18 60.779999 61.139999 ... …
Borut Flis
  • 15,715
  • 30
  • 92
  • 119
1
2