Skip to content

BUG: Series creation with datetime64 with non-ns unit as object dtype #13876

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

Merged
merged 1 commit into from
Aug 2, 2016

Conversation

sinhrks
Copy link
Member

@sinhrks sinhrks commented Aug 1, 2016

  • tests added / passed
  • passes git diff upstream/master | flake8 --diff
  • whatsnew entry

found a bug related to datetime64 with non-ns unit.

# OK
pd.Series(np.array([np.datetime64('2011-01-01')]))
#0   2011-01-01
# dtype: datetime64[ns]

# OK
pd.Series([np.datetime64('2011-01-01')], dtype=object)
#0    2011-01-01
# dtype: object

# NG
pd.Series(np.array([np.datetime64('2011-01-01')]), dtype=object)
#0    1970-01-01 00:00:00.000014
# dtype: object

# OK
pd.Series(np.array([np.datetime64('2011-01-01', 'ns')]), dtype=object)
#0    2011-01-01 00:00:00
# dtype: object

@sinhrks sinhrks added the Dtype Conversions Unexpected or buggy dtype conversions label Aug 1, 2016
@sinhrks sinhrks added this to the 0.19.0 milestone Aug 1, 2016
@@ -788,7 +787,8 @@ def test_datetime_likes(self):
tm.assert_numpy_array_equal(res_false, exp_false)

# index
for idx in [pd.Index(case), pd.Index(case, dtype='category')]:
for idx in [pd.Index(case), pd.Index(case, dtype='category'),
pd.Index(case, dtype=object)]:
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unrelated to the fix itself, but adding more tests to duplicated (this test revealed the bug).

@sinhrks sinhrks added the Bug label Aug 1, 2016
@codecov-io
Copy link

codecov-io commented Aug 2, 2016

Current coverage is 85.23% (diff: 100%)

Merging #13876 into master will increase coverage by <.01%

@@             master     #13876   diff @@
==========================================
  Files           140        140          
  Lines         50456      50458     +2   
  Methods           0          0          
  Messages          0          0          
  Branches          0          0          
==========================================
+ Hits          43007      43010     +3   
+ Misses         7449       7448     -1   
  Partials          0          0          

Powered by Codecov. Last update d4f95fd...00244d0

@jreback jreback merged commit 299fb75 into pandas-dev:master Aug 2, 2016
@jreback
Copy link
Contributor

jreback commented Aug 2, 2016

thanks @sinhrks

@sinhrks sinhrks deleted the datetime64_obj branch August 2, 2016 11:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Dtype Conversions Unexpected or buggy dtype conversions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants