Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 157
gh-624 : Added index parameter to to_dict and added axis argument to Series.add_suffix(), DataFrame.add_suffix(), Series.add_prefix() and DataFrame.add_prefix()#638
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
Uh oh!
There was an error while loading. Please reload this page.
Merged
Changes from all commits
Commits
Show all changes
9 commits Select commit Hold shift + click to select a range
bc4cc76 added arguments
ramvikrams 61f2936 changed axis parameters
ramvikrams 094b155 req changes and created a different overload and corrected index args
ramvikrams aa2d0c7 creating overloads
ramvikrams 71d5b9d Update frame.pyi
ramvikrams 583dfa4 corrected diff overload args
ramvikrams c9d0f54 added the tests
ramvikrams 4f4c87f corrected the tests
ramvikrams c6f9ba0 Update test_series.py
ramvikrams File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -268,32 +268,61 @@ class DataFrame(NDFrame, OpsMixin): | ||
| @overload | ||
| def to_dict( | ||
| self, | ||
| orient: Literal["dict", "list", "series", "split", "tight", "index"], | ||
| orient: Literal["records"], | ||
| into: Mapping | type[Mapping], | ||
| index: Literal[True] = ..., | ||
| ) -> list[Mapping[Hashable, Any]]: ... | ||
| @overload | ||
| def to_dict( | ||
| self, | ||
| orient: Literal["records"], | ||
| into: None = ..., | ||
| index: Literal[True] = ..., | ||
| ) -> list[dict[Hashable, Any]]: ... | ||
| @overload | ||
| def to_dict( | ||
| self, | ||
| orient: Literal["dict", "list", "series", "index"], | ||
| into: Mapping | type[Mapping], | ||
| index: Literal[True] = ..., | ||
| ) -> Mapping[Hashable, Any]: ... | ||
| @overload | ||
| def to_dict( | ||
| self, | ||
| orient: Literal["dict", "list", "series", "split", "tight", "index"] = ..., | ||
| *, | ||
| orient: Literal["split", "tight"], | ||
| into: Mapping | type[Mapping], | ||
| index: bool = ..., | ||
| ) -> Mapping[Hashable, Any]: ... | ||
| @overload | ||
| def to_dict( | ||
| self, | ||
| orient: Literal["dict", "list", "series", "split", "tight", "index"] = ..., | ||
| into: None = ..., | ||
| ) -> dict[Hashable, Any]: ... | ||
| orient: Literal["dict", "list", "series", "index"] = ..., | ||
| *, | ||
| into: Mapping | type[Mapping], | ||
| index: Literal[True] = ..., | ||
| ) -> Mapping[Hashable, Any]: ... | ||
| @overload | ||
| def to_dict( | ||
| self, | ||
| orient: Literal["records"], | ||
| orient: Literal["split", "tight"] = ..., | ||
| *, | ||
| into: Mapping | type[Mapping], | ||
| ) -> list[Mapping[Hashable, Any]]: ... | ||
| index: bool = ..., | ||
| ) -> Mapping[Hashable, Any]: ... | ||
| @overload | ||
| def to_dict( | ||
| self, orient: Literal["records"], into: None = ... | ||
| ) -> list[dict[Hashable, Any]]: ... | ||
| self, | ||
| orient: Literal["dict", "list", "series", "index"] = ..., | ||
| into: None = ..., | ||
| index: Literal[True] = ..., | ||
| ) -> dict[Hashable, Any]: ... | ||
| @overload | ||
| def to_dict( | ||
| self, | ||
| orient: Literal["split", "tight"] = ..., | ||
| into: None = ..., | ||
| index: bool = ..., | ||
| ) -> dict[Hashable, Any]: ... | ||
ramvikrams marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading. Please reload this page. | ||
| def to_gbq( | ||
| self, | ||
| destination_table: str, | ||
| @@ -1400,8 +1429,8 @@ class DataFrame(NDFrame, OpsMixin): | ||
| level: Level | None = ..., | ||
| fill_value: float | None = ..., | ||
| ) -> DataFrame: ... | ||
| def add_prefix(self, prefix: _str) -> DataFrame: ... | ||
| def add_suffix(self, suffix: _str) -> DataFrame: ... | ||
| def add_prefix(self, prefix: _str, axis: Axis | None = None) -> DataFrame: ... | ||
| def add_suffix(self, suffix: _str, axis: Axis | None = None) -> DataFrame: ... | ||
| @overload | ||
| def all( | ||
| self, | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1813,3 +1813,15 @@ def test_types_apply_set() -> None: | ||
| {"list1": [1, 2, 3], "list2": ["a", "b", "c"], "list3": [True, False, True]} | ||
| ) | ||
| check(assert_type(series_of_lists.apply(lambda x: set(x)), pd.Series), pd.Series) | ||
| def test_prefix_summix_axis() -> None: | ||
| s = pd.Series([1, 2, 3, 4]) | ||
| check(assert_type(s.add_suffix("_item", axis=0), pd.Series), pd.Series) | ||
| check(assert_type(s.add_suffix("_item", axis="index"), pd.Series), pd.Series) | ||
| check(assert_type(s.add_prefix("_item", axis=0), pd.Series), pd.Series) | ||
| check(assert_type(s.add_prefix("_item", axis="index"), pd.Series), pd.Series) | ||
ramvikrams marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading. Please reload this page. | ||
| if TYPE_CHECKING_INVALID_USAGE: | ||
| check(assert_type(s.add_prefix("_item", axis=1), pd.Series), pd.Series) # type: ignore[arg-type] # pyright: ignore[reportGeneralTypeIssues] | ||
| check(assert_type(s.add_suffix("_item", axis="columns"), pd.Series), pd.Series) # type: ignore[arg-type] # pyright: ignore[reportGeneralTypeIssues] | ||
ramvikrams marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading. Please reload this page. | ||
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.