Skip to content

BUG: pd.to_datetime doesn't raises AttributeError with specific input… #13909

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 5, 2016

Conversation

conquistador1492
Copy link
Contributor

@conquistador1492 conquistador1492 commented Aug 4, 2016

…s when errors='ignore'(#12424)

if val.view('i8') == NPY_NAT:
oresult[i] = NaT
else:
oresult[i] = np.nan
Copy link
Contributor

Choose a reason for hiding this comment

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

what are you trying to catch here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

AttributeError: 'float' object has no attribute 'view'

Copy link
Member

@sinhrks sinhrks Aug 4, 2016

Choose a reason for hiding this comment

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

i don't think the error is intended. can u fix to handle nan properly?

Copy link
Contributor

@jreback jreback Aug 4, 2016

Choose a reason for hiding this comment

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

you need to do a more explict check, something like:
I don't think it can be anything else.

if PyFloat_Check(val): # we *already* know its a null.
    oresult[i] = np.nan
else:
    orseult[i] = NaT

@codecov-io
Copy link

codecov-io commented Aug 5, 2016

Current coverage is 85.30% (diff: 100%)

Merging #13909 into master will not change coverage

@@             master     #13909   diff @@
==========================================
  Files           139        139          
  Lines         50138      50138          
  Methods           0          0          
  Messages          0          0          
  Branches          0          0          
==========================================
  Hits          42769      42769          
  Misses         7369       7369          
  Partials          0          0          

Powered by Codecov. Last update e5ee5d2...58d3d19

@@ -568,6 +568,11 @@ def test_value_counts_datetime_outofbounds(self):
exp = pd.Series([3, 2, 1], index=exp_index)
tm.assert_series_equal(res, exp)

res = pd.to_datetime(pd.Series(['2362-01-01', np.nan]),
Copy link
Contributor

Choose a reason for hiding this comment

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

add the issue number as a comment here

@jreback
Copy link
Contributor

jreback commented Aug 5, 2016

pls add a release note as well

@jreback jreback added this to the 0.19.0 milestone Aug 5, 2016
@jreback jreback merged commit 3186fef into pandas-dev:master Aug 5, 2016
@jreback
Copy link
Contributor

jreback commented Aug 5, 2016

thanks!

@conquistador1492 conquistador1492 deleted the issue_12424 branch August 5, 2016 20:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Datetime Datetime data dtype
Projects
None yet
Development

Successfully merging this pull request may close these issues.

pd.to_datetime raises AttributeError with specific inputs when errors='ignore'
4 participants