-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
API: resolution for date_range, to_datetime, timedelta_range, to_timedelta #49060
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
Comments
For the If the |
That wouldn't be a problem, would be identical to
In that particular case they are all pytimedelta objects which all get microsecond resolution. Suppose instead we have
This should avoid a major perf hit or API change for currently-working cases. The downside is it isn't inferring the best reso so much as the highest viable reso. Also wouldn't match scalar behavior. |
Okay that is reasonable. I think if constructors have arguments that allow multiple ways to specify resolutions ( |
Since I could not find anything on this in the current release notes for 2.0.0 I wanted to ask if there are any updates on this issue? |
there is now a "unit"keyword in date_range and timedelta_range that specifies resolution. Haven't done to_datetime and to_timedelta yet. |
Documentation is silent about what is resolution and its possible values. Please add link for possible values on this page https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.date_range.html Edit: if you pass any string to unit, Value error would provide you with documentation: ValueError("'unit' must be one of 's', 'ms', 'us', 'ns'") |
In 2.0 we'll support non-nanosecond datetime64 and timedelta64. ATM date_range, timedelta_range, to_datetime, and to_timedelta still are nano-only. This issue is about how to support non-nano in these functions.
Two main options: inference or a keyword. A keyword would be something like
pd.date_range(start, end, periods=10, reso="ms")
, and the default would be "ns". This is the simplest thing to implement, but adds more API surface.inference for date_range would look at start and stop to determine the correct resolution. This could get messy if e.g. start and stop have different resos. ATM im thinking this isn't worth it.
inference for to_datetime (really in array_to_datetime) is more compelling in part bc I expect to_datetime to be called by library code for e.g. io.
The text was updated successfully, but these errors were encountered: