-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: Dataframe constructor when given dict with None value #14392
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
BUG: Dataframe constructor when given dict with None value #14392
Conversation
Current coverage is 85.26% (diff: 100%)
|
@brandonmburroughs Do you have time to update this PR according to the discussion in #14381 (so keep as None) |
@@ -5693,6 +5693,8 @@ def _homogenize(data, index, dtype=None): | |||
else: | |||
v = dict(v) | |||
v = lib.fast_multiget(v, oindex.values, default=NA) | |||
elif v is None: | |||
v = np.nan |
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.
you can change the check where this breaks now (if subarr.ndim = 0
) to
if getattr(subarr, 'ndim', 0) == 0
then it will fall into that expression where the None
will be correctly inferred
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.
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.
Yes, thanks!
@jorisvandenbossche Yes, I'll update based upon the discussion and push the changes in the next day or so. |
ebb75a4
to
271c0d8
Compare
# Dict with None value | ||
frame_none = DataFrame(dict(a=None), index=[0]) | ||
frame_nan = DataFrame(dict(a=[None]), index=[0]) | ||
tm.assert_frame_equal(frame_none, frame_nan) |
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.
Can you add an assert to check that the value in the frame is actually None
(and not np.nan)
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.
Good idea, added.
271c0d8
to
231c2e4
Compare
@brandonmburroughs Thanks a lot! |
…t with None value (pandas-dev#14392) (cherry picked from commit 60a335e)
Version 0.19.1 * tag 'v0.19.1': (43 commits) RLS: v0.19.1 DOC: update whatsnew/release notes for 0.19.1 (pandas-dev#14573) [Backport pandas-dev#14545] BUG/API: Index.append with mixed object/Categorical indices (pandas-dev#14545) DOC: rst fixes [Backport pandas-dev#14567] DEPR: add deprecation warning for com.array_equivalent (pandas-dev#14567) [Backport pandas-dev#14551] PERF: casting loc to labels dtype before searchsorted (pandas-dev#14551) [Backport pandas-dev#14536] BUG: DataFrame.quantile with NaNs (GH14357) (pandas-dev#14536) [Backport pandas-dev#14520] BUG: don't close user-provided file handles in C parser (GH14418) (pandas-dev#14520) [Backport pandas-dev#14392] BUG: Dataframe constructor when given dict with None value (pandas-dev#14392) [Backport pandas-dev#14514] BUG: Don't parse inline quotes in skipped lines (pandas-dev#14514) [Bacport pandas-dev#14543] BUG: tseries ceil doc fix (pandas-dev#14543) [Backport pandas-dev#14541] DOC: Simplify the gbq integration testing procedure for contributors (pandas-dev#14541) [Backport pandas-dev#14527] BUG/ERR: raise correct error when sql driver is not installed (pandas-dev#14527) [Backport pandas-dev#14501] BUG: fix DatetimeIndex._maybe_cast_slice_bound for empty index (GH14354) (pandas-dev#14501) [Backport pandas-dev#14442] DOC: Expand on reference docs for read_json() (pandas-dev#14442) BLD: fix 3.4 build for cython to 0.24.1 [Backport pandas-dev#14492] BUG: Accept unicode quotechars again in pd.read_csv [Backport pandas-dev#14496] BLD: Support Cython 0.25 [Backport pandas-dev#14498] COMPAT/TST: fix test for range testing of negative integers to neg powers [Backport pandas-dev#14476] PERF: performance regression in Series.asof (pandas-dev#14476) ...
git diff upstream/master | flake8 --diff