8000 ENH: nullable Float32/64 ExtensionArray by jorisvandenbossche · Pull Request #34307 · pandas-dev/pandas · GitHub
[go: up one dir, main page]

Skip to content

ENH: nullable Float32/64 ExtensionArray #34307

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 35 commits into from
Sep 30, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
cddc939
ENH: nullable Float32/64 ExtensionArray
jorisvandenbossche May 15, 2020
6a1d822
fix doctest
jorisvandenbossche May 22, 2020
f43f021
add basic whatsnew note
jorisvandenbossche May 22, 2020
ffdd65c
typo
jorisvandenbossche May 22, 2020
3d189f9
Merge remote-tracking branch 'upstream/master' into EA-floating
jorisvandenbossche May 29, 2020
ff3b937
fix astype to string
jorisvandenbossche May 29, 2020
13b8281
Merge remote-tracking branch 'upstream/master' into EA-floating
jorisvandenbossche Jun 15, 2020
4c1d06c
Merge remote-tracking branch 'upstream/master' into EA-floating
jorisvandenbossche Jun 19, 2020
ebbc64d
clean-up arithmetic tests to align with integer/boolean tests
jorisvandenbossche Jun 19, 2020
94be5f2
Merge remote-tracking branch 'upstream/master' into EA-floating
jorisvandenbossche Jun 22, 2020
8cf0d47
updates for feedback
jorisvandenbossche Jun 22, 2020
f7cc1be
fix string array construction
jorisvandenbossche Jun 22, 2020
107b083
fix mypy
jorisvandenbossche Jun 22, 2020
ba1e62c
Merge remote-tracking branch 'upstream/master' into EA-floating
jorisvandenbossche Jul 3, 2020
879d3e0
Merge remote-tracking branch 'upstream/master' into EA-floating
jorisvandenbossche Jul 11, 2020
ed9a14b
rename _FloatingDtype -> FloatingDtype
jorisvandenbossche Jul 11, 2020
c16ca4c
update astype implementation to follow IntegerArray changes
jorisvandenbossche Jul 11, 2020
aa45aac
clean-up tests
jorisvandenbossche Jul 11, 2020
25eb1ba
remove usage of deprecated check_less_precise
jorisvandenbossche Jul 12, 2020
b78c041
Merge remote-tracking branch 'upstream/master' into EA-floating
jorisvandenbossche Sep 18, 2020
45b98f2
fixup merge + skip astype(string) for float32
jorisvandenbossche Sep 18, 2020
314b6a9
linting
jorisvandenbossche Sep 18, 2020
a157806
add back type ignore
jorisvandenbossche Sep 18, 2020
81456f9
whatsnew 1.2
jorisvandenbossche Sep 19, 2020
71009c3
update whatsnew
jorisvandenbossche Sep 19, 2020
56d2311
add fixture
jorisvandenbossche Sep 19, 2020
65a2060
share some dtype properties
jorisvandenbossche Sep 19, 2020
8b36098
update ensure_float
jorisvandenbossche Sep 19, 2020
7f3e965
Merge remote-tracking branch 'upstream/master' into EA-floating
jorisvandenbossche Sep 23, 2020
66d6939
remove skip for float32 conversion to string
jorisvandenbossche Sep 23, 2020
e0c9d9a
Merge remote-tracking branch 'upstream/master' into EA-floating
jorisvandenbossche Sep 29, 2020
d37b815
code formatting
jorisvandenbossche Sep 29, 2020
44e699a
Update doc/source/whatsnew/v1.2.0.rst
jorisvandenbossche Sep 30, 2020
b42b61d
Update pandas/core/arrays/floating.py
jorisvandenbossche Sep 30, 2020
edf9618
ignore mypy bug
jorisvandenbossche Sep 30, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
share some dtype properties
  • Loading branch information
jorisvandenbossche committed Sep 19, 2020
commit 65a2060eb42fee7c5c4e9050c621473ae4ee7236
2 changes: 1 addition & 1 deletion pandas/core/arrays/boolean.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class BooleanDtype(BaseMaskedDtype):
name = "boolean"

@property
def type(self) -> Type[np.bool_]:
def type(self) -> Type:
return np.bool_

@property
Expand Down
18 changes: 0 additions & 18 deletions pandas/core/arrays/floating.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,31 +47,13 @@ class FloatingDtype(BaseMaskedDtype):
The attributes name & type are set when these subclasses are created.
"""

name: str
base = None
type: Type

def __repr__(self) -> str:
Copy link
Contributor

Choose a reason for hiding this comment

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

should e in the BaseMaskedArray class

Copy link
Member Author

Choose a reason for hiding this comment

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

should be in the BaseMaskedArray class

There would be nothing else using it, as the Integer/Boolean also have custom implementations. It needs some refactor to be able to share.

return f"{self.name}Dtype()"

@property
def _is_numeric(self) -> bool:
return True

@cache_readonly
def numpy_dtype(self) -> np.dtype:
""" Return an instance of our numpy dtype """
return np.dtype(self.type)

@cache_readonly
def kind(self) -> str:
return self.numpy_dtype.kind

@cache_readonly
def itemsize(self) -> int:
""" Return the number of bytes in this dtype """
return self.numpy_dtype.itemsize

@classmethod
def construct_array_type(cls) -> Type["FloatingArray"]:
"""
Expand Down
18 changes: 0 additions & 18 deletions pandas/core/arrays/integer.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,6 @@ class _IntegerDtype(BaseMaskedDtype):
The attributes name & type are set when these subclasses are created.
"""

name: str
base = None
type: Type

def __repr__(self) -> str:
sign = "U" if self.is_unsigned_integer else ""
return f"{sign}Int{8 * self.itemsize}Dtype()"
Expand All @@ -66,20 +62,6 @@ def is_unsigned_integer(self) -> bool:
def _is_numeric(self) -> bool:
return True

@cache_readonly
def numpy_dtype(self) -> np.dtype:
""" Return an instance of our numpy dtype """
return np.dtype(self.type)

@cache_readonly
def kind(self) -> str:
return self.numpy_dtype.kind

@cache_readonly
def itemsize(self) -> int:
""" Return the number of bytes in this dtype """
return self.numpy_dtype.itemsize

@classmethod
def construct_array_type(cls) -> Type["IntegerArray"]:
"""
Expand Down
20 changes: 17 additions & 3 deletions pandas/core/arrays/masked.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from pandas._libs import lib, missing as libmissing
from pandas._typing import Scalar
from pandas.errors import AbstractMethodError
from pandas.util._decorators import doc
from pandas.util._decorators import cache_readonly, doc

from pandas.core.dtypes.base import ExtensionDtype
from pandas.core.dtypes.common import (
Expand Down Expand Up @@ -34,11 +34,25 @@ class BaseMaskedDtype(ExtensionDtype):
Base class for dtypes for BasedMaskedArray subclasses.
"""

name: str
base = None
type: Type

na_value = libmissing.NA

@property
@cache_readonly
def numpy_dtype(self) -> np.dtype:
raise AbstractMethodError
""" Return an instance of our numpy dtype """
return np.dtype(self.type)

@cache_readonly
def kind(self) -> str:
return self.numpy_dtype.kind

@cache_readonly
def itemsize(self) -> int:
""" Return the number of bytes in this dtype """
return self.numpy_dtype.itemsize

@classmethod
def construct_array_type(cls) -> Type["BaseMaskedArray"]:
Expand Down
0