Skip to content

Conversation

@felipemaion
Copy link
Contributor

^^^
- :meth:`DataFrame.to_orc` now raising ``ValueError`` when non-default :class:`Index` is given (:issue:`51828`)
- :meth:`DataFrame.to_sql` now raising ``ValueError`` when the name param is left empty while using SQLAlchemy to connect (:issue:`52675`)
- Bug in :func:`json_normalize`, json_normalize cannot parse metadata fields list type (:issue:`#37782`)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
- Bug in :func:`json_normalize`, json_normalize cannot parse metadata fields list type (:issue:`#37782`)
- Bug in :func:`json_normalize`, json_normalize cannot parse metadata fields list type (:issue:`37782`)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@mroeschke I'm seeing the message: This branch has conflicts that must be resolved
Only those with write access to this repository can merge pull requests.
Conflicting files
doc/source/whatsnew/v2.1.0.rst

Can you please take a look and guide me on this?

Copy link
Member

Choose a reason for hiding this comment

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

Please follow these constructions to update your branch and fix the conflict: https://pandas.pydata.org/docs/development/contributing.html#updating-your-pull-request



@pytest.fixture
def parse_metadata_fields_list_type():
Copy link
Member

Choose a reason for hiding this comment

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

Can you just hardcode this in the function?

Copy link
Contributor Author

@felipemaion felipemaion May 5, 2023

Choose a reason for hiding this comment

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

@mroeschke like that?

    def test_fields_list_type_normalize(self):
        parse_metadata_fields_list_type=[{"values": [1, 2, 3], "metadata": {"listdata": [1, 2]}}]
        result = json_normalize(
            parse_metadata_fields_list_type,
            record_path=["values"],
            meta=[["metadata", "listdata"]],
        )
        expected = DataFrame(
            {0: [1, 2, 3], "metadata.listdata": [[1, 2], [1, 2], [1, 2]]}
        )
        tm.assert_frame_equal(result, expected)
        
    Should I push it? I did this as function just by looking other examples in the file.
    Let me know.

Copy link
Member

Choose a reason for hiding this comment

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

Yes

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@mroeschke I just did it. But things looks different. I'm not sure if it was pushed properly. Can you check please?
(My first PR for a big project)

@mroeschke mroeschke added the IO JSON read_json, to_json, json_normalize label May 5, 2023
@mroeschke mroeschke added this to the 2.1 milestone May 8, 2023
@mroeschke mroeschke merged commit f112661 into pandas-dev:main May 8, 2023
@mroeschke
Copy link
Member

Thanks @felipemaion

Rylie-W pushed a commit to Rylie-W/pandas that referenced this pull request May 19, 2023
* Fix BUG: pandas-dev#37782

* Fix BUG: pandas-dev#37782

* Fix BUG: 37782 - Hardcoded test data

* Fix BUG: 37782 - Hardcoded test data

* Update pandas/io/json/_normalize.py

Co-authored-by: Matthew Roeschke <10647082+mroeschke@users.noreply.github.com>

* Fix BUG: 37782 - typo

* Fix BUG: 37782 - typo

* Update doc/source/whatsnew/v2.1.0.rst

---------

Co-authored-by: Matthew Roeschke <10647082+mroeschke@users.noreply.github.com>
Daquisu pushed a commit to Daquisu/pandas that referenced this pull request Jul 8, 2023
* Fix BUG: pandas-dev#37782

* Fix BUG: pandas-dev#37782

* Fix BUG: 37782 - Hardcoded test data

* Fix BUG: 37782 - Hardcoded test data

* Update pandas/io/json/_normalize.py

Co-authored-by: Matthew Roeschke <10647082+mroeschke@users.noreply.github.com>

* Fix BUG: 37782 - typo

* Fix BUG: 37782 - typo

* Update doc/source/whatsnew/v2.1.0.rst

---------

Co-authored-by: Matthew Roeschke <10647082+mroeschke@users.noreply.github.com>
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BUG: json_normalize cannot parse metadata fields list type

2 participants