-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
REF: use BlockManager.apply in csv code #36150
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
Changes from all commits
01bcedd
3e4da00
aef2351
7b93513
29c9ee3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -593,7 +593,7 @@ def astype(self, dtype, copy: bool = False, errors: str = "raise"): | |
|
||
# use native type formatting for datetime/tz/timedelta | ||
if self.is_datelike: | ||
values = self.to_native_types() | ||
values = self.to_native_types().values | ||
|
||
# astype formatting | ||
else: | ||
|
@@ -684,7 +684,7 @@ def to_native_types(self, na_rep="nan", quoting=None, **kwargs): | |
values = np.array(values, dtype="object") | ||
|
||
values[mask] = na_rep | ||
return values | ||
return self.make_block(values) | ||
|
||
# block actions # | ||
def copy(self, deep: bool = True): | ||
|
@@ -1774,7 +1774,7 @@ def to_native_types(self, na_rep="nan", quoting=None, **kwargs): | |
|
||
# TODO(EA2D): reshape not needed with 2D EAs | ||
# we are expected to return a 2-d ndarray | ||
return values.reshape(1, len(values)) | ||
return self.make_block(values) | ||
|
||
def take_nd( | ||
self, indexer, axis: int = 0, new_mgr_locs=None, fill_value=lib.no_default | ||
|
@@ -2021,7 +2021,7 @@ def to_native_types( | |
values = np.array(values, dtype="object") | ||
|
||
values[mask] = na_rep | ||
return values | ||
return self.make_block(values) | ||
|
||
from pandas.io.formats.format import FloatArrayFormatter | ||
|
||
|
@@ -2033,7 +2033,8 @@ def to_native_types( | |
quoting=quoting, | ||
fixed_width=False, | ||
) | ||
return formatter.get_result_as_array() | ||
res = formatter.get_result_as_array() | ||
return self.make_block(res) | ||
|
||
|
||
class ComplexBlock(FloatOrComplexBlock): | ||
|
@@ -2192,7 +2193,7 @@ def to_native_types(self, na_rep="NaT", date_format=None, **kwargs): | |
result = dta._format_native_types( | ||
na_rep=na_rep, date_format=date_format, **kwargs | ||
) | ||
return np.atleast_2d(result) | ||
return self.make_block(result) | ||
|
||
def set(self, locs, values): | ||
""" | ||
|
@@ -2408,7 +2409,8 @@ def fillna(self, value, **kwargs): | |
def to_native_types(self, na_rep="NaT", **kwargs): | ||
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. can you now type all of these to return a Block? 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. sure 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. actually adding this makes mypy complain about signature mismatch, rather not futz with it ATM |
||
""" convert to our native types format """ | ||
tda = self.array_values() | ||
return tda._format_native_types(na_rep, **kwargs) | ||
res = tda._format_native_types(na_rep, **kwargs) | ||
return self.make_block(res) | ||
|
||
|
||
class BoolBlock(NumericBlock): | ||
|
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.
.to_numpy() ?
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.
no, to_native_types returns a Block