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
1
vote
1 answer

Convert a List of Dates as String to PANDAS DatetimeIndex

I have a PANDAS Series of dates (as strings) and frequencies as integers: date 2020-02-02 24 2020-02-03 43 2020-02-07 465 2020-02-08 123 2020-02-09 234 But I need them as the output of events in the code below: all_days =…
woody70
  • 85
  • 9
1
vote
1 answer

how to convert multiindex to datetimeindex? (without reindex())

I need to use "modin" dataframes, which dont not work with multindexes (at one point i do df.reindex(idx), where idx is a multilevel index), so: how can I convert a multi index to a single index? (merging both levels together) minimal…
La-Li-Lu-Le-Low
  • 191
  • 2
  • 15
1
vote
1 answer

Python: Why using asfreq() is dropping my last row of data?

I can not figure it out why when I am using pandas asfreq() method it is droping my last row of data. data = rental_2012_09_to_2020_06.copy() data.drop(columns='postcode', inplace=True) data.columns = ['Quarter_End', 'Rental_Median'] data.index =…
juanmsanga
  • 13
  • 3
1
vote
2 answers

Heatmap with pandas DateTimeIndex on both axis

I would like to make a heatmap from a pandas DataFrame (or Series) with DateTimeIndex so that I have hours on the x-axis and days on the y-axis, both ticklabels displayed in DateTimeIndex style. If I do the following: import pandas as pd …
matthme
  • 253
  • 2
  • 7
1
vote
1 answer

Pandas not converting certain columns of dataframe to datetimeindex

My dataframe until now, and I am trying to convert cols which is a list of all columns from 0 to 188 ( cols = list(hdata.columns[ range(0,188) ]) ) which are in this format yyyy-mm to datetimeIndex. There are other few columns as well which are…
Anurag Dhadse
  • 1,722
  • 1
  • 13
  • 26
1
vote
1 answer

How to return NaN for missing month in pd.DatetimeIndex

I have a dataset with some incomplete dates. I.e., while the default is "2020-03-20" some dates only have the year (i.e. 2020). In these cases (year only) it seems like pd.DatetimeIndex(["2020"]).month[or day] sets the month and day to 01-01…
Franka
  • 33
  • 4
1
vote
2 answers

Time range to index in pandas

For each datapoint (in this example a and b), its specific occurrence time frame is specified: pd.DataFrame([ {'from': pd.Timestamp('2020-01-01'), 'to': pd.Timestamp('2020-01-05')}, {'from': pd.Timestamp('2020-01-02'), 'to':…
Michael Dorner
  • 17,587
  • 13
  • 87
  • 117
1
vote
1 answer

xarray: coords conversion to datetime64

I have a NetCDF4 file that i'm handling using xarray. The dataset has a "time" coordinate as dtype=object and i would like to convert it ot datetime64 in order to simplify plotting of the variables contained in the file. My plan was to create a new…
Asblut
  • 13
  • 1
  • 4
1
vote
1 answer

Inconsistent behavior of pandas DatetimeIndex.round?

I encountered a strange, very unexpected behavior in the round-method of pandas.DatetimeIndex: import pandas as pd import datetime as dt t1 = pd.DatetimeIndex([dt.datetime(2013,12,5,1,30,0), dt.datetime(2013,12,5,2,30,0), …
Durtal
  • 1,063
  • 3
  • 11
1
vote
3 answers

Python pandas - join date & time columns into datetime column with timezone

I have a dataset that has a date column and a time column, I'm trying to combine them in a DateTime column but I'm facing an issue with the month & date parts of it being reversed For example: Date Time 1/2/2019 3:29:59 PM 4/2/2019 9:15:59…
Abhay
  • 827
  • 9
  • 34
1
vote
1 answer

Pandas: combine resampling and group by. How do I average values within same groups before summing them up in a time bin?

I have tabular data (described by col1, col2,...) associated to a Timestamp and a custom made Group. Example: Group Col1 Col2 Col3 Time 2020-05-18 A 10 20 30 2020-05-18 B 10 20 30 2020-05-18 C 10 20 …
Marvin
  • 37
  • 5
1
vote
3 answers

Join two Pandas Series with different DateTimeIndex

I have two pandas series with DateTimeIndex. I'd like to join these two series such that the resulting DataFrame uses the index of the first series and "matches" the values from the second series accordingly (using a linear interpolation in the…
maz
  • 143
  • 8
1
vote
1 answer

Sublcassing Pandas DatetimeIndex

I am trying to create a custom datetime class in python to support a time series model. After reviewing some of the existing python libraries I found that the pandas DatetimeIndex class provides much of the functionality I am looking for, but I…
hydrophile
  • 21
  • 3
1
vote
2 answers

KeyError using Index

Apologies for the fairly basic question. Basically I have a large dataframe where I'm pulling out the top dates for the sum of certain values. Looks like this: hv_toploss =…
1
vote
1 answer

Apply DatetimeIndex as filter on a Dateframe with datetime values

Ok, so I'm just learning to work with DatetimeIndex and Dateframe objects. I came across a new problem I can't directly see the solution to and I was hoping someone maybe has an elegant solution to it using pandas functions I maybe don't know of…
CptSnuggles
  • 137
  • 1
  • 3
  • 11