-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
BUG: pandas.Series.dt.round inconsistent behaviour on NAT's with different arguments? #14940
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
yep, this looks buggy. need to mask the NaT's before and replace after, use Further looks like
prob also buggy for PR's welcome! |
I was passing the example code though debugger and investigated the next. The
Lets consider the first example
Deeper investigation gave next results
In the second case, the value isn't rounding which is correct cause we use math round. But I think we definitely use much smarter round, because we are using the large numbers and could neglect by math round. |
@discort you don't need to worry about the calculation on the NaT at all. simply use |
…erent arguments closes pandas-dev#14940 Author: discort <[email protected]> Closes pandas-dev#15124 from discort/dt_round_bug_14940 and squashes the following commits: 9e77191 [discort] added a test for Timestamp 52c897a [discort] BUG: added maybe_mask_results to '_round' method
Code Sample
Problem description
This is the output I get:
In the first case (freq argument 's') NaT are preserved (I would say, as I expect). However, in the second and third case, NaT's are converted to some apparently weird date time. If I don't miss some particular information (which in case after I googled and browsed the docs shouldn't be that hidden), this seems to be a bug
Expected Output
0 2010-01-01 23:14:12
1 NaT
Name: dtime, dtype: datetime64[ns]
0 2010-01-01 23:14:10.000000000
1 NaT
Name: dtime, dtype: datetime64[ns]
0 2010-01-01 23:14:00
1 NaT
Name: dtime, dtype: datetime64[ns]
Output of
pd.show_versions()
pandas: 0.18.1
nose: None
pip: 9.0.1
setuptools: 24.0.2
Cython: None
numpy: 1.11.1
scipy: 0.17.1
statsmodels: None
xarray: None
IPython: None
sphinx: None
patsy: None
dateutil: 2.5.3
pytz: 2016.4
blosc: None
bottleneck: None
tables: None
numexpr: None
matplotlib: 1.5.1
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: None
lxml: 3.6.0
bs4: None
html5lib: None
httplib2: None
apiclient: None
sqlalchemy: 1.0.13
pymysql: None
psycopg2: 2.6.2 (dt dec pq3 ext lo64)
jinja2: 2.8
boto: None
pandas_datareader: None
The text was updated successfully, but these errors were encountered: