Skip to content

Construction of series with na and datetime dtype #46068

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

Conversation

weikhor
Copy link
Contributor

@weikhor weikhor commented Feb 19, 2022

@pep8speaks
Copy link

pep8speaks commented Feb 19, 2022

Hello @weikhor! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻

Comment last updated at 2022-03-09 16:19:51 UTC

@weikhor weikhor changed the title Construction of series with n as and datetime dtype Construction of series with nas and datetime dtype Feb 19, 2022
@weikhor weikhor changed the title Construction of series with nas and datetime dtype Construction of series with na and datetime dtype Feb 19, 2022
elif (
is_float_dtype(self.dtype)
and needs_i8_conversion(dtype)
and not np.isnan(values).any()
Copy link
Member

Choose a reason for hiding this comment

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

can you add a comment about why this check is needed

Copy link
Member

Choose a reason for hiding this comment

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

also use self.hasnans as it may be cached

Copy link
Contributor Author

Choose a reason for hiding this comment

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

can you add a comment about why this check is needed

Hi, I just notice this. it is my mistake to add this.

@jreback jreback added Constructors Series/DataFrame/Index/pd.array Constructors Dtype Conversions Unexpected or buggy dtype conversions Index Related to the Index class or subclasses labels Feb 27, 2022
@@ -774,6 +775,9 @@ def _try_cast(
return maybe_cast_to_datetime(arr, dtype)
# TODO: copy?

if isinstance(dtype, IntervalDtype) and isna(arr).all():
return np.asarray(arr).astype(IntervalDtype, copy=False)
Copy link
Member

Choose a reason for hiding this comment

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

this will always raise won't it?

@weikhor
Copy link
Contributor Author

weikhor commented Mar 14, 2022

I close this since I stuck this for long time. I get simpler task. Thank for review.

@weikhor weikhor closed this Mar 14, 2022
@weikhor weikhor deleted the construction_of_series_with_NAs_and__datetime_dtype branch May 31, 2022 16:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Constructors Series/DataFrame/Index/pd.array Constructors Dtype Conversions Unexpected or buggy dtype conversions Index Related to the Index class or subclasses
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: Construction of Series with NAs and interval-of-datetime dtype raises error
4 participants