Skip to content

Datetime index issue? #303

Answered by kernc
harshhacks asked this question in Q&A
Apr 8, 2021 · 1 comments · 12 replies
Discussion options

You must be logged in to vote

The code uses:

# Convert index to datetime index
if (not isinstance(data.index, pd.DatetimeIndex) and
not isinstance(data.index, pd.RangeIndex) and
# Numeric index with most large numbers
(data.index.is_numeric() and
(data.index > pd.Timestamp('1975').timestamp()).mean() > .8)):
try:
data.index = pd.to_datetime(data.index, infer_datetime_format=True)
except ValueError:
pass

if not isinstance(data.index, pd.DatetimeIndex):
warnings.warn('Data index is not datetime.…

Replies: 1 comment 12 replies

Comment options

You must be logged in to vote
12 replies
@kernc
Comment options

kernc Apr 9, 2021
Maintainer

@harshhacks
Comment options

@harshhacks
Comment options

@kernc
Comment options

kernc Apr 9, 2021
Maintainer

@harshhacks
Comment options

Answer selected by harshhacks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants