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

Multiple selection in pandas dataframe by DateTimeIndex

I'm trying to select certain rows in a dataframe based on a list. If you set up the index of a dataframe as a DatetimeIndex you can select just by: example_df['2018-12-12'] But you can't select multiple dates like this: example_df[['2018-12-12',…
skarit
  • 11
  • 1
  • 3
0
votes
1 answer

How to append infinity to a pandas DatetimeIndex

I have a pandas DatetimeIndex and I want to append infinity to the end, because I want to use it to make bins - with pandas.cut(..., right=False) - and I want the last bin to have infinity as an upper limit. Thus, I can later map whatever date…
Thanasis Mattas
  • 484
  • 4
  • 16
0
votes
1 answer

Transforming a Pandas timeseries dataframe to a 3D array

I have a timeindexed dataframe with two columns "USER_ID" and "Daily_BALANCE". The dataframe shows the daily balance of users for the month of April 2018 (so 30 observations for each user). I need to generate from that dataframe a 3D numpy array…
alya
  • 35
  • 5
0
votes
0 answers

how to slice element from DateTimeIndex in pandas created using pd.date_range

I have created an index with name 'dates' using pandas.date_range and I want to slice the 5th element from the Datetimeindex. How to slice the 5th element from it. dates = pd.date_range(start = '1-Sep-2017',end =…
0
votes
0 answers

How to index a DateTimeIndex with a label list

I am having troubles indexing a pandas dataframe with pandas.DatetimeIndex index. The problem arises when i try to index the dataframe with a list of labels, using .loc accessor (on the contrary, indexing with a list of indexes through .iloc…
IvanProsperi94
  • 109
  • 2
  • 7
0
votes
1 answer

Apply function to rolling window on multi-indexed DataFrame, get only one aggregated result per date and category

I have a multi-index based on dates and a category, which looks like this: D Date G 2004-01-01 A 1 A 2 A 3 A 4 B 101 B 102 …
0
votes
1 answer

how to fix TypeError: Only valid with DatetimeIndex

i m trying to make candlesticks with matplotlib. got a csv file like this. ,CloseTime ,OpenPrice,HighPrice, LowPrice, ClosePrice, Volume, Adj Volume 0,1523836800,503.0, 535.01184,497.09033, 533.72046, 13180.739,…
Alper Aşan
  • 65
  • 1
  • 7
0
votes
1 answer

How to select data from dates range

I have the following datetime index and dataframe object: dti = pd.DatetimeIndex(['2019-06-02', '2019-06-16', '2019-07-07', '2019-07-21', '2019-08-04'], name='Date') df = pd.DataFrame(columns=['Open', 'High', 'Low', 'Close'], index=dti, …
akushyn
  • 73
  • 1
  • 5
0
votes
1 answer

How to use a variable with multiple possible formats in loc to slice a pandas dataframe with a DatetimeIndex

I need to define a function that will perform several operations on a dataframe containing a DatetimeIndex. One of these operations is to slice the dataframe based on a period or date passed as one of the function arguments. When using loc within a…
Javgs
  • 43
  • 6
0
votes
1 answer

How do I stop pandas dataframe.resample('T') from automatically adding extra indexes to dataframe?

I'm trying to downsample a dataframe that has minute by minute data into 5 minute bins. Here is my current code: df = pd.read_csv('stockPrices/closingPrices-apr3.csv',index_col='date',parse_dates=True) df['close'] = df['close'].shift() df5min =…
0
votes
1 answer

error using resample , says 'only valid with datetimeindex' even though i used to_datetime and set_index

I have a dataframe with two columns: 'case' and 'datetime' . index------ case----------outDateTime 71809----10180227.0-----2013-01-01 01:41:01 71810----10180229.0-----2013-01-01 04:20:05 71811----10180230.0-----2013-01-01…
0
votes
2 answers

How to disallow keys other than Timestamps in DatetimeIndex?

Pandas does not restrict DatetimeIndex keys to only Timestamps. Why it is so and is there any way to make such restriction? df = pd.DataFrame({"A":{"2019-01-01":12.0,"2019-01-03":27.0,"2019-01-04":15.0}, …
viscacha
  • 25
  • 6
0
votes
2 answers

Why can't I index row by datetime index in pandas?

I can't seem to index rows using datetime index with pandas. Information on my dataframe shows that the index is datetimeindex: DatetimeIndex: 223 entries, 2013-10-29 to 2017-05-29 Data columns (total 6…
halo09876
  • 2,725
  • 12
  • 51
  • 71
0
votes
1 answer

Plotting pd.Series object does not show year correctly

I am graphing the results of the measurements of a humidity sensor over time. I'm using Python 3.7.1 and Pandas 0.24.2. I have a list called dateTimeList with date and time strings: dateTimeList = ['15.3.2019 11:44:27', '15.3.2019 12:44:33',…
0
votes
2 answers

Pandas DatetimeIndex: Number of periods in a frequency string?

How can I get a count of the number of periods in a Pandas DatetimeIndex using a frequency string (offset alias)? For example, let's say I have the following DatetimeIndex: idx = pd.date_range("2019-03-01", periods=10000, freq='5T') I would like to…
Turanga1
  • 123
  • 1
  • 7