Questions tagged [datetimeindex]

Immutable ndarray of datetime64 data, represented internally as int64

Immutable ndarray of datetime64 data, represented internally as int64, and which can be boxed to Timestamp objects that are subclasses of datetime and carry metadata such as frequency information.

325 questions
0
votes
1 answer

Efficiently Iterate Through Datetime Index to Set Time Boundaries

I have a dataframe df: col1 col2 col3 2020-01-02 08:50:00 360.0 -131.0 -943.0 2020-01-02 08:52:01 342.0 -130.0 -1006.0 2020-01-02 08:55:04 321.0 -130.0 -997.0 ... ... ... ... 2022-01-03 14:44:56 …
0
votes
0 answers

Stumped. How do I convert my datetime format to an acceptable format for pandas and mplfinance?

I am trying to use various charting packages for ohlc bar charting. Some success but I keep getting stuck on "TypeError: Expect data.index as DatetimeIndex". The samples that I copy work perfectly fine, like this below: import yfinance as…
Jimbo
  • 3
  • 3
0
votes
1 answer

Pandas datetime series report values at specific intervals

Given data from print(cot_report_splice) date symbol Net Positioning 2020-10-20 PA 3413 PL 7825 2020-10-27 PA 3468 PL 10051 2020-11-03 PA 2416 ... …
SJ1
  • 15
  • 4
0
votes
0 answers

Python Pandas 1.5.x takes too long to retrieve dict values, when the values are serieses using DatetimeIndex with TZ

This was not an issue prior to Pandas 1.5.x. Last version working fast as expected: 1.4.4. The below tests demonstrate a conversion of a dict to a dataframe (df = pd.DataFrame(dict)), however, the issue exists also when performing a simple value…
Aerodyne
  • 11
  • 3
0
votes
1 answer

Merge two Pandas DataFrames on their DatetimeIndex columns

I am trying to merge two Pandas DataFrames on DatetimeIndex columns. Each df contains different daily measurement data for an overlapping period, one day with several columns per line. I want to end up with a df merged on the DatetimeIndex with…
AstroFloyd
  • 405
  • 5
  • 14
0
votes
1 answer

how can i use dataframe and datetimeindex to return rolling 12-month?

Imagine a pandas dataframe with 2 columns (“Manager Returns” and “Benchmark Returns”) and a DatetimeIndex of monthly frequency. Please write a function to calculate the rolling 12-month manager alpha and rolling-12 month tracking error (both…
0
votes
1 answer

Pandas DateTimeIndex indexing random multiple days

I am trying to extract random multiple whole day data from pandas DateTimeIndex series, But it returns only the first hour data when the multiple days are passed as a list. dt = pd.date_range('11-1-2022','11-4-2022',freq='6H').to_series() When I…
kbk78
  • 139
  • 4
0
votes
2 answers

Extrapolating time series data into the future by repeating/scaling existing values

I have hourly data on electricity consumption for a specific day. I would like to use this data to "predict" the hourly electricity consumption for the following days. The value for the following day should be the value from the same hour the day…
0
votes
1 answer

Python: How do I multiply DataFrame values by number prior to a certain date

Consider the following DataFrame: df: ticker A B C date 2022-01-02 145 100 100 2022-01-03 450 200 241 2022-01-04 100 200 NaN 2022-01-05 424 324 222 2022-01-06 …
MathMan 99
  • 665
  • 1
  • 7
  • 19
0
votes
0 answers

Find the index of specific date in nc file

I want to find the time index corresponding to the date 2018-08-21 import netCDF4 from netCDF4 import num2date, date2num, date2index import numpy as np f=netCDF4.Dataset('../t.cdf') times=f.variables['time'] dates = num2date(times[:],…
0
votes
1 answer

Pandas date_range with custom monthly frequency in which the number of days between each month changes in a periodic manner

I want to create a DatetimeIndex representing months but the number of days between successive months differs in a periodic manner. I want it so that every third index the date increases by 5 weeks (35 days) and for all others only 4 weeks (28…
Luca Guarro
  • 1,085
  • 1
  • 11
  • 25
0
votes
1 answer

Python: Loop over datetimeindex based on different periods

I have a DataFrame and I am trying to loop over the datetmeindex based on different frequencies: data = [[99330,12,122],[1123,1230,1287],[123,101,812739],[1143,12301230,252],[234,342,4546],[2445,3453,3457],[7897,8657,5675], …
MathMan 99
  • 665
  • 1
  • 7
  • 19
0
votes
1 answer

Add new column to dataframe that is another column's values from the month before based repeating datetime index with other columns as identifiers

If I have this df called feature_df: Each row represents a particular "cohort" of mortgage loan groups. I want to select the Wac from each row and create a new column called lagged_WAC which is filled with Wac values from the month prior, based on…
hulio_entredas
  • 675
  • 1
  • 12
0
votes
2 answers

How to add multiple years to DateTimeIndex in Pandas

I'd like to add multiple years to my date index in pandas, but have not been able to do so: ts is a dataframe with a series and relevant dates. I would like to extend those dates by an additional several years in order to add other series for…
0
votes
1 answer

How to use datetime index from a Series to modify another series?

I have 2 Series with datetime index. I want to edit the values (float) of the first one at each corresponding daily minimum of the second one. I tried ser_1.loc[ser_2.groupby(ser_2.index.day_of_year).idxmin()] += 1 But I get this error : raise…
Hurrdof
  • 23
  • 5