-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
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
Conversation
needs a test |
There was a problem hiding this 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
Modified as requested. |
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 |
I added a test in a place that seemed appropriate. It passed on my platform. |
@@ -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() |
There was a problem hiding this comment.
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): |
There was a problem hiding this comment.
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
.
There was a problem hiding this 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
can you merge master and add a test |
closing this as stale, though its a nice change, needs a rebase and comments addressed. |
black pandas
git diff upstream/master -u -- "*.py" | flake8 --diff