Skip to content

BUG: fixed json_normalize for subrecords with NoneTypes (#20030) #20399

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 2 commits into from
Mar 20, 2018

Conversation

aerymilts
Copy link
Contributor

@aerymilts aerymilts commented Mar 18, 2018

TST: additional coverage for the test cases

DOC: added changes to whatsnew/v0.23.0.txt

Checklist for other PRs (remove this part if you are doing a PR for the pandas documentation sprint):

TST: additional coverage for the test cases

DOC: added changes to whatsnew/v0.23.0.txt

BUG: changed how nan is declared for backward compatibility - python2.7
@codecov
Copy link

codecov bot commented Mar 18, 2018

Codecov Report

Merging #20399 into master will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #20399      +/-   ##
==========================================
+ Coverage   91.77%   91.77%   +<.01%     
==========================================
  Files         152      152              
  Lines       49205    49215      +10     
==========================================
+ Hits        45159    45169      +10     
  Misses       4046     4046
Flag Coverage Δ
#multiple 90.16% <100%> (ø) ⬆️
#single 41.84% <0%> (-0.01%) ⬇️
Impacted Files Coverage Δ
pandas/io/json/normalize.py 96.93% <100%> (+0.06%) ⬆️
pandas/core/window.py 96.26% <0%> (-0.01%) ⬇️
pandas/plotting/_core.py 82.27% <0%> (ø) ⬆️
pandas/util/testing.py 84.11% <0%> (+0.16%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7273ea0...76d2d91. Read the comment docs.

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.

looks good. some minor comments. ping on green.

@@ -226,6 +237,21 @@ def test_non_ascii_key(self):
result = json_normalize(json.loads(testjson))
tm.assert_frame_equal(result, expected)

def test_missing_field(self, author_missing_data):
result = json_normalize(author_missing_data)
Copy link
Contributor

Choose a reason for hiding this comment

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

can you add the issue number as a comment. & a 1-liner explaining the test purpose

@@ -322,3 +348,26 @@ def test_json_normalize_errors(self):
['general', 'trade_version']],
errors='raise'
)

def test_nonetype_dropping(self):
data = [
Copy link
Contributor

Choose a reason for hiding this comment

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

same, pls add the gh issue number as a comment and 1 liner

def test_missing_field(self, author_missing_data):
result = json_normalize(author_missing_data)
ex_data = [
{'author_name.first': float('nan'),
Copy link
Contributor

Choose a reason for hiding this comment

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

use np.nan here

@jreback jreback added Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate IO JSON read_json, to_json, json_normalize labels Mar 20, 2018
@jreback jreback added this to the 0.23.0 milestone Mar 20, 2018
@aerymilts
Copy link
Contributor Author

aerymilts commented Mar 20, 2018

@jreback I have updated the PR, let me know if you need me to squash the changes instead.

@jreback jreback merged commit 01882ba into pandas-dev:master Mar 20, 2018
@jreback
Copy link
Contributor

jreback commented Mar 20, 2018

thanks @aerymilts nice patch! keep em coming!

nehiljain added a commit to nehiljain/pandas that referenced this pull request Mar 21, 2018
…ame_describe

* upstream/master: (158 commits)
  Add link to "Craft Minimal Bug Report" blogpost (pandas-dev#20431)
  BUG: fixed json_normalize for subrecords with NoneTypes (pandas-dev#20030) (pandas-dev#20399)
  BUG: ExtensionArray.fillna for scalar values (pandas-dev#20412)
  DOC" update the Pandas core window rolling count docstring" (pandas-dev#20264)
  DOC: update the pandas.DataFrame.plot.hist docstring (pandas-dev#20155)
  DOC: Only use ~ in class links to hide prefixes. (pandas-dev#20402)
  Bug: Allow np.timedelta64 objects to index TimedeltaIndex (pandas-dev#20408)
  DOC: add disallowing of Series construction of len-1 list with index to whatsnew (pandas-dev#20392)
  MAINT: Remove weird pd file
  DOC: update the Index.isin docstring (pandas-dev#20249)
  BUG: Handle all-NA blocks in concat (pandas-dev#20382)
  DOC: update the pandas.core.resample.Resampler.fillna docstring (pandas-dev#20379)
  BUG: Don't raise exceptions splitting a blank string (pandas-dev#20067)
  DOC: update the pandas.DataFrame.cummax docstring (pandas-dev#20336)
  DOC: update the pandas.core.window.x.mean docstring (pandas-dev#20265)
  DOC: update the api.types.is_number docstring (pandas-dev#20196)
  Fix linter (pandas-dev#20389)
  DOC: Improved the docstring of pandas.Series.dt.to_pytimedelta (pandas-dev#20142)
  DOC: update the pandas.Series.dt.is_month_end docstring (pandas-dev#20181)
  DOC: update the window.Rolling.min docstring (pandas-dev#20263)
  ...
@aerymilts aerymilts deleted the pr/20030 branch March 23, 2018 02:49
@aerymilts aerymilts restored the pr/20030 branch March 23, 2018 02:50
@aerymilts aerymilts deleted the pr/20030 branch March 23, 2018 02:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
IO JSON read_json, to_json, json_normalize Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

json_normalize does not normalize subrecords properly if any subrecords values are NoneType
2 participants