-
-
Notifications
You must be signed in to change notification settings - Fork 144
ENH: Improve dtypes #386
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
ENH: Improve dtypes #386
Changes from 5 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
322a4cb
ENH: Improve dtypes
bashtage df9762e
CLN: Remove unnecesssary parts of classes (eq, hash)
bashtage a687e1f
CLN/ENH: Restructure Dtypes and add typing info
bashtage 3f87ef0
ENH: Improvements to dtypes
bashtage f67279b
TST: Fix test for python 3.8
5041b57
Merge remote-tracking branch 'upstream/main' into dtypes
bashtage 9bae8b5
CLN: Fix issues identified
bashtage 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
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 |
---|---|---|
@@ -1,8 +1,12 @@ | ||
import numpy as np | ||
import pyarrow as pa | ||
|
||
from pandas._libs.missing import NAType | ||
|
||
from pandas.core.dtypes.base import StorageExtensionDtype | ||
|
||
class ArrowDtype(StorageExtensionDtype): | ||
pyarrow_dtype: pa.DataType | ||
def __init__(self, pyarrow_dtype: pa.DataType) -> None: ... | ||
@property | ||
def na_value(self) -> NAType: ... |
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
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 |
---|---|---|
@@ -1,33 +1,22 @@ | ||
import numpy as np | ||
|
||
from pandas._typing import ( | ||
Dtype, | ||
Scalar, | ||
npt, | ||
) | ||
|
||
from pandas.core.dtypes.base import ExtensionDtype | ||
from pandas.core.dtypes.dtypes import ( | ||
register_extension_dtype as register_extension_dtype, | ||
) | ||
|
||
# merged types from pylance | ||
|
||
class SparseDtype(ExtensionDtype): | ||
def __init__(self, dtype: Dtype = ..., fill_value: Scalar | None = ...) -> None: ... | ||
def __hash__(self): ... | ||
def __eq__(self, other) -> bool: ... | ||
@property | ||
def fill_value(self): ... | ||
@property | ||
def kind(self): ... | ||
@property | ||
def type(self): ... | ||
def __init__( | ||
self, dtype: Dtype | npt.DTypeLike = ..., fill_value: Scalar | None = ... | ||
) -> None: ... | ||
@property | ||
def subtype(self): ... | ||
def fill_value(self) -> Scalar | None: ... | ||
@property | ||
def name(self): ... | ||
@classmethod | ||
def construct_array_type(cls): ... | ||
@classmethod | ||
def construct_from_string(cls, string): ... | ||
@classmethod | ||
def is_dtype(cls, dtype): ... | ||
def update_dtype(self, dtype): ... | ||
def subtype(self) -> Dtype: ... | ||
def update_dtype(self, dtype: SparseDtype | npt.DTypeLike) -> SparseDtype: ... | ||
bashtage marked this conversation as resolved.
Show resolved
Hide resolved
|
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 |
---|---|---|
@@ -1,125 +1,71 @@ | ||
import datetime as dt | ||
from typing import ( | ||
Any, | ||
Sequence, | ||
Literal, | ||
) | ||
|
||
import numpy as np | ||
from pandas.core.indexes.base import Index | ||
from pandas.core.series import Series | ||
|
||
from pandas._libs.tslibs import ( # , timezones as timezones | ||
Period as Period, | ||
Timestamp, | ||
from pandas._libs import NaTType | ||
from pandas._libs.tslibs import BaseOffset | ||
from pandas._typing import ( | ||
Ordered, | ||
npt, | ||
) | ||
from pandas._typing import Ordered | ||
|
||
from .base import ExtensionDtype as ExtensionDtype | ||
|
||
_str = str | ||
|
||
def register_extension_dtype(cls: type[ExtensionDtype]) -> type[ExtensionDtype]: ... | ||
|
||
class BaseMaskedDtype(ExtensionDtype): ... | ||
|
||
class PandasExtensionDtype(ExtensionDtype): | ||
bashtage marked this conversation as resolved.
Show resolved
Hide resolved
|
||
subdtype = ... | ||
str: _str | None = ... | ||
str: str | None = ... | ||
num: int = ... | ||
shape: tuple[int, ...] = ... | ||
itemsize: int = ... | ||
base = ... | ||
isbuiltin: int = ... | ||
isnative: int = ... | ||
def __hash__(self) -> int: ... | ||
|
||
@classmethod | ||
def reset_cache(cls) -> None: ... | ||
|
||
class CategoricalDtypeType(type): ... | ||
|
||
class CategoricalDtype(PandasExtensionDtype, ExtensionDtype): | ||
name: _str = ... | ||
type: type[CategoricalDtypeType] = ... | ||
kind: _str = ... | ||
str: _str = ... | ||
base = ... | ||
def __init__( | ||
self, categories: Sequence[Any] | None = ..., ordered: Ordered = ... | ||
self, | ||
categories: Series | Index | list[Any] | None = ..., | ||
ordered: Ordered = ..., | ||
) -> None: ... | ||
@classmethod | ||
def construct_from_string(cls, string: _str) -> CategoricalDtype: ... | ||
def __hash__(self) -> int: ... | ||
def __eq__(self, other) -> bool: ... | ||
@classmethod | ||
def construct_array_type(cls): ... | ||
@staticmethod | ||
def validate_ordered(ordered: Ordered) -> None: ... | ||
@staticmethod | ||
def validate_categories(categories, fastpath: bool = ...): ... | ||
def update_dtype(self, dtype: _str | CategoricalDtype) -> CategoricalDtype: ... | ||
@property | ||
def categories(self) -> Index: ... | ||
@property | ||
def ordered(self) -> Ordered: ... | ||
|
||
class DatetimeTZDtype(PandasExtensionDtype): | ||
type: type[Timestamp] = ... | ||
kind: _str = ... | ||
str: _str = ... | ||
num: int = ... | ||
base = ... | ||
na_value = ... | ||
def __init__(self, unit: _str = ..., tz=...) -> None: ... | ||
def __init__( | ||
self, unit: Literal["ns"] = ..., tz: str | int | dt.tzinfo | None = ... | ||
) -> None: ... | ||
@property | ||
def unit(self): ... | ||
def unit(self) -> Literal["ns"]: ... | ||
@property | ||
def tz(self): ... | ||
@classmethod | ||
def construct_array_type(cls): ... | ||
@classmethod | ||
def construct_from_string(cls, string: _str): ... | ||
def tz(self) -> dt.tzinfo: ... | ||
@property | ||
def name(self) -> _str: ... | ||
def __hash__(self) -> int: ... | ||
def __eq__(self, other) -> bool: ... | ||
def na_value(self) -> NaTType: ... | ||
|
||
class PeriodDtype(PandasExtensionDtype): | ||
type: type[Period] = ... | ||
kind: _str = ... | ||
str: _str = ... | ||
base = ... | ||
num: int = ... | ||
def __new__(cls, freq=...): ... | ||
@property | ||
def freq(self): ... | ||
@classmethod | ||
def construct_from_string(cls, string: _str): ... | ||
def __init__(self, freq: str | BaseOffset = ...): ... | ||
@property | ||
def name(self) -> _str: ... | ||
def freq(self) -> BaseOffset: ... | ||
@property | ||
def na_value(self): ... | ||
def __hash__(self) -> int: ... | ||
def __eq__(self, other) -> bool: ... | ||
@classmethod | ||
def is_dtype(cls, dtype) -> bool: ... | ||
@classmethod | ||
def construct_array_type(cls): ... | ||
def na_value(self) -> NaTType: ... | ||
def __from_arrow__(self, array): ... | ||
bashtage marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
class IntervalDtype(PandasExtensionDtype): | ||
name: _str = ... | ||
kind: _str = ... | ||
str: _str = ... | ||
base = ... | ||
num: int = ... | ||
def __new__(cls, subtype=...): ... | ||
@property | ||
def subtype(self): ... | ||
@classmethod | ||
def construct_array_type(cls): ... | ||
@classmethod | ||
def construct_from_string(cls, string: _str): ... | ||
def __init__(self, subtype: str | npt.DTypeLike | None = ...): ... | ||
@property | ||
def type(self): ... | ||
def __hash__(self) -> int: ... | ||
def __eq__(self, other) -> bool: ... | ||
@classmethod | ||
def is_dtype(cls, dtype) -> bool: ... | ||
def subtype(self) -> np.dtype | None: ... | ||
def __from_arrow__(self, array): ... | ||
bashtage marked this conversation as resolved.
Show resolved
Hide resolved
|
Oops, something went wrong.
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.