Skip to content

feat: add table to JsonSeriesOrient Literals #482

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 5 commits into from
Dec 27, 2022

Conversation

DarioHett
Copy link
Contributor

Includes the Literal table for the orient argument in s.to_json().

@@ -318,7 +318,7 @@ MergeHow: TypeAlias = Union[JoinHow, Literal["cross"]]
JsonFrameOrient: TypeAlias = Literal[
"split", "records", "index", "columns", "values", "table"
]
JsonSeriesOrient: TypeAlias = Literal["split", "records", "index"]
JsonSeriesOrient: TypeAlias = Literal["split", "records", "index", "table"]
Copy link
Member

Choose a reason for hiding this comment

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

There seem to be a few more orientation values https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.to_json.html that can be added.

Ideally, we would also have a test for this.

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Collaborator

@Dr-Irv Dr-Irv left a comment

Choose a reason for hiding this comment

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

Can you add a test that tests all the possible arguments for the orient argument? Modify the function test_json_series() in test_io.py .

@DarioHett
Copy link
Contributor Author

Commit d8d9c20 should fix the requested changes.

A more general question - can we not import types from pandas-stubs directly? With typing.get_args() an extension in _typing.pyi would translate to an extension in the test parameters.

@DarioHett DarioHett requested review from Dr-Irv and twoertwein and removed request for Dr-Irv and twoertwein December 24, 2022 11:21
@DarioHett DarioHett requested review from twoertwein and removed request for Dr-Irv December 24, 2022 16:21
tests/test_io.py Outdated
@@ -387,12 +387,39 @@ def test_json():
check(assert_type(read_json(bin_json), DataFrame), DataFrame)


def test_json_series():
def test_json_series(orient):
Copy link
Member

Choose a reason for hiding this comment

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

Is the orient argument of test_json_series unused?

Copy link
Collaborator

@Dr-Irv Dr-Irv left a comment

Choose a reason for hiding this comment

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

thanks @DarioHett

@Dr-Irv Dr-Irv merged commit 04cc404 into pandas-dev:main Dec 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Series.to_json - Overload variants arguments raise error despite match
3 participants