Skip to content

Added try-except clause to catch numpy error. #27970

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

Closed
wants to merge 6 commits into from
Closed

Added try-except clause to catch numpy error. #27970

wants to merge 6 commits into from

Conversation

dustanlevenstein
Copy link

@dustanlevenstein dustanlevenstein commented Aug 17, 2019

@jbrockmendel
Copy link
Member

needs a test

Copy link
Contributor

@jreback jreback left a comment

Choose a reason for hiding this comment

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

always add tests first
we are also trying to remove try/excepts except in very limited circumstances as they hide errors

@dustanlevenstein
Copy link
Author

Modified as requested.

@jbrockmendel
Copy link
Member

by "needs a test" I meant that this PR fixes some bug and we need a unit test (goes somewhere in pandas/tests/) to test that we get the correct behavior

@gfyoung gfyoung added Constructors Series/DataFrame/Index/pd.array Constructors Dtype Conversions Unexpected or buggy dtype conversions ExtensionArray Extending pandas with custom dtypes or arrays. labels Aug 18, 2019
@dustanlevenstein
Copy link
Author

I added a test in a place that seemed appropriate. It passed on my platform.

@dustanlevenstein
Copy link
Author

The last version didn't pass the checks. I'm confused because the error doesn't seem to be related to anything that I edited...

Screenshot from 2019-08-18 15-06-44
Screenshot from 2019-08-18 15-05-19

@@ -69,6 +69,10 @@ def test_empty_frame_dtypes_ftypes(self):
norows_df = pd.DataFrame(columns=list("abc"))
assert_series_equal(norows_df.dtypes, pd.Series(np.object, index=list("abc")))

cat = pd.CategoricalDtype()
Copy link
Member

Choose a reason for hiding this comment

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

Could you add tests for other extension dtypes (e.g. datetime with timezones and/or period)

@@ -223,7 +223,9 @@ def init_dict(data, index, columns, dtype=None):

# no obvious "empty" int column
if missing.any() and not is_integer_dtype(dtype):
if dtype is None or np.issubdtype(dtype, np.flexible):
if is_categorical_dtype(dtype):
Copy link
Member

@mroeschke mroeschke Aug 18, 2019

Choose a reason for hiding this comment

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

Based on the original issue this needs to be is_extension_array_dtype.

Copy link
Member

@mroeschke mroeschke left a comment

Choose a reason for hiding this comment

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

Also needs a whatsnew entry in 1.0.0

@jreback
Copy link
Contributor

jreback commented Sep 8, 2019

can you merge master and add a test

@jreback
Copy link
Contributor

jreback commented Oct 3, 2019

closing this as stale, though its a nice change, needs a rebase and comments addressed.

@jreback jreback closed this Oct 3, 2019
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 ExtensionArray Extending pandas with custom dtypes or arrays.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DataFrame constructor fails with extension dtype and columns
5 participants