-
-
Notifications
You must be signed in to change notification settings - Fork 18.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ENH: Timestamp/DTI. to epoch time #14772
Comments
This also works, but exposing internal impl, verbose and not user friendly
|
If we would add user facing functionality, I think I would like |
I changed this to make this an enhancement for a simple |
since timestamp now has timestamp method, should,we use the same name for DTI? |
yes this would be reasonable (though to be honest the |
I also don't really like the name. It is rather confusing given that we already have a |
I am partial to |
One question: what to do with NaTs? In [5]: pd.DatetimeIndex(['2017', '2018', None]).values.astype('datetime64[s]').astype("i8")
Out[5]: array([ 1483228800, 1514764800, -9223372036854775808]) Do we value having integer dtype more? I think so in this case. |
Second question: timezones. Unix time is defined in UTC, so should we
This will necessitate an |
third question: how to handle higher-precision components? In [6]: pd.DatetimeIndex(['2017-01-01T00:00:00.01', '2017-01-01T00:00:00.02']).to_epoch()
Out[6]: array([1483228800, 1483228800]) I don't think we should use floats and fractional components. So that leaves truncating or rounding to the nearest |
could a pd.array(pd.DatetimeIndex(['2017', '2018', None]).values.astype('datetime64[s]'), dtype='Int64') raises
|
yes there are various use cases where we could do things like this |
add a
.to_epoch(unit='s')
method toTimestamp
andDatetimeIndex
that returns the epoch for that unit. I think would default this tos
as that seems pretty common, but allow any of our units.The text was updated successfully, but these errors were encountered: