-
- Notifications
You must be signed in to change notification settings - Fork 19.4k
ENH: EADtype._find_compatible_dtype #53106
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
Closed
Closed
Changes from 1 commit
Commits
Show all changes
18 commits Select commit Hold shift + click to select a range
a0f8c31 ENH: EADtype._maybe_promote
jbrockmendel 0770a07 simplify check
jbrockmendel 9be179b docstring
jbrockmendel 1271e26 Merge branch 'main' into enh-maybe_promote
jbrockmendel 48a2f6d Merge branch 'main' into enh-maybe_promote
jbrockmendel c62dcaa Better name, tests
jbrockmendel c85a3eb Updat edoc
jbrockmendel fb0b03a Fix setitem-with-expansion for Decimal
jbrockmendel b809fd7 Merge branch 'main' into enh-maybe_promote
jbrockmendel deab083 Merge branch 'main' into enh-maybe_promote
jbrockmendel b565439 Merge branch 'main' into enh-maybe_promote
jbrockmendel c3fbbcb Merge branch 'main' into enh-maybe_promote
jbrockmendel 995f4b4 Merge branch 'main' into enh-maybe_promote
jbrockmendel 6f481f9 Merge branch 'main' into enh-maybe_promote
jbrockmendel 0790932 Merge branch 'main' into enh-maybe_promote
jbrockmendel 2b9a092 Merge branch 'main' into enh-maybe_promote
jbrockmendel a85a6d4 Merge branch 'main' into enh-maybe_promote
jbrockmendel 92227ef Merge branch 'main' into enh-maybe_promote
jbrockmendel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Better name, tests
- Loading branch information
commit c62dcaafde69e21e300e2c2ec582f29ec5bf9b8d
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
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 |
|---|---|---|
| | @@ -671,7 +671,7 @@ def _get_common_dtype(self, dtypes: list[DtypeObj]) -> DtypeObj | None: | |
| | ||
| return find_common_type(non_cat_dtypes) | ||
| | ||
| def _maybe_promote(self, item) -> tuple[DtypeObj, Any]: | ||
| def _find_compatible_dtype(self, item) -> tuple[DtypeObj, Any]: | ||
| from pandas.core.dtypes.missing import is_valid_na_for_dtype | ||
| | ||
| if item in self.categories or is_valid_na_for_dtype( | ||
| | @@ -1569,7 +1569,7 @@ def _get_common_dtype(self, dtypes: list[DtypeObj]) -> DtypeObj | None: | |
| except (KeyError, NotImplementedError): | ||
| return None | ||
| | ||
| def _maybe_promote(self, item) -> tuple[DtypeObj, Any]: | ||
| def _find_compatible_dtype(self, item) -> tuple[DtypeObj, Any]: | ||
| from pandas.core.dtypes.cast import maybe_promote | ||
| from pandas.core.dtypes.missing import is_valid_na_for_dtype | ||
| | ||
| | @@ -2316,7 +2316,7 @@ def __from_arrow__(self, array: pa.Array | pa.ChunkedArray): | |
| arr = array.cast(self.pyarrow_dtype, safe=True) | ||
| return array_class(arr) | ||
| | ||
| def _maybe_promote(self, item: Any) -> tuple[DtypeObj, Any]: | ||
| def _find_compatible_dtype(self, item: Any) -> tuple[DtypeObj, Any]: | ||
| if isinstance(item, pa.Scalar): | ||
| if not item.is_valid: | ||
| # TODO: ask joris for help making these checks more robust | ||
| Member Author 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. @jorisvandenbossche any thoughts here? (not time-sensitive) | ||
| | ||
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
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.
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.
what happens if item is null? The pyarrow null
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.
IIUC pyarrow nulls are now typed. id prefer to be strict about making these match, but dont care that much. am hoping @jorisvandenbossche will weigh in