Skip to content

Commit 41baaa3

Browse files
author
Jiang Yue
committed
add whatsnew entry
1 parent e53b620 commit 41baaa3

File tree

4 files changed

+10
-3
lines changed

4 files changed

+10
-3
lines changed

doc/source/whatsnew/v0.25.0.rst

+1
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ Other Enhancements
133133
- :meth:`DataFrame.describe` now formats integer percentiles without decimal point (:issue:`26660`)
134134
- Added support for reading SPSS .sav files using :func:`read_spss` (:issue:`26537`)
135135
- Added new option ``plotting.backend`` to be able to select a plotting backend different than the existing ``matplotlib`` one. Use ``pandas.set_option('plotting.backend', '<backend-module>')`` where ``<backend-module`` is a library implementing the pandas plotting API (:issue:`14130`)
136+
- :meth:`io.json.json_normalize` now accepts a `fill_value` argument to fill NaN fields in given columns (:issue:`16918`)
136137

137138
.. _whatsnew_0250.api_breaking:
138139

pandas/_libs/lib.pyx

+2-1
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,8 @@ def dicts_to_array(dicts: list, columns: list, fill_value=None):
321321

322322
result = np.empty((n, k), dtype='O')
323323
if fill_value:
324-
onan = [fill_value[col] if col in fill_value else np.nan for col in columns]
324+
onan = ([fill_value[col] if col in fill_value
325+
else np.nan for col in columns])
325326
else:
326327
onan = list(np.full(k, np.nan))
327328

pandas/io/json/normalize.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,6 @@ def json_normalize(data, record_path=None, meta=None,
109109
----------
110110
data : dict or list of dicts
111111
Unserialized JSON objects
112-
fill_value: dict, default None
113-
default na values for specified columns
114112
record_path : string or list of strings, default None
115113
Path in each object to list of records. If not passed, data will be
116114
assumed to be an array of records
@@ -135,6 +133,11 @@ def json_normalize(data, record_path=None, meta=None,
135133
136134
.. versionadded:: 0.20.0
137135
136+
fill_value : dict, default None
137+
default na values for specified columns
138+
139+
.. versionadded:: 0.25.0
140+
138141
Returns
139142
-------
140143
frame : DataFrame

pandas/tests/io/json/test_normalize.py

+2
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ def deep_nested():
3838
}
3939
]
4040

41+
4142
@pytest.fixture
4243
def deep_nested_missing():
4344
# deeply nested data with some missing values
@@ -65,6 +66,7 @@ def deep_nested_missing():
6566
}
6667
]
6768

69+
6870
@pytest.fixture
6971
def state_data():
7072
return [

0 commit comments

Comments
 (0)