-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
ENH: Preserve Series index on json_normalize
#57422
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
Changes from 4 commits
ecf941b
f5cc0f6
ec6aef2
decdc23
a326898
8461a3d
5ad9bf6
12d7178
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -561,6 +561,14 @@ def test_top_column_with_leading_underscore(self): | |
|
||
tm.assert_frame_equal(result, expected) | ||
|
||
def test_series_index(self, state_data): | ||
idx = [7, 8] | ||
series = Series(state_data, index=idx) | ||
result = json_normalize(series) | ||
assert (result.index == idx).all() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you make
|
||
result = json_normalize(series, "counties") | ||
assert (result.index == np.array(idx).repeat([3, 2])).all() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similar comment to the one above |
||
|
||
|
||
class TestNestedToRecord: | ||
def test_flat_stays_flat(self): | ||
|
@@ -893,4 +901,5 @@ def test_series_non_zero_index(self): | |
"elements.c": [np.nan, np.nan, 3.0], | ||
} | ||
) | ||
expected.index = [1, 2, 3] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: Could you put this in the |
||
tm.assert_frame_equal(result, expected) |
Uh oh!
There was an error while loading. Please reload this page.
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.