-
-
Notifications
You must be signed in to change notification settings - Fork 19.1k
BUG: preserve object-dtype index when accessing DataFrame column / PERF: improve perf of Series fastpath constructor #42950
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 1 commit
64f9690
57659b8
64e7403
972185f
973713f
a133162
15e274e
33fde4f
0f1ee8a
22cc921
94cc2ad
da90ef1
2443961
0431a11
daebcf1
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 |
---|---|---|
|
@@ -441,7 +441,11 @@ def __init__( | |
data = SingleArrayManager.from_array(data, index) | ||
|
||
generic.NDFrame.__init__(self, data) | ||
self.name = name | ||
if fastpath: | ||
# skips validation of the name | ||
object.__setattr__(self, "_name", name) | ||
else: | ||
self.name = name | ||
self._set_axis(0, index, fastpath=True) | ||
|
||
def _init_dict(self, data, index=None, dtype: Dtype | None = None): | ||
|
@@ -531,23 +535,23 @@ def _set_axis(self, axis: int, labels, fastpath: bool = False) -> None: | |
if not fastpath: | ||
labels = ensure_index(labels) | ||
|
||
if labels._is_all_dates: | ||
deep_labels = labels | ||
if isinstance(labels, CategoricalIndex): | ||
deep_labels = labels.categories | ||
|
||
if not isinstance( | ||
deep_labels, (DatetimeIndex, PeriodIndex, TimedeltaIndex) | ||
): | ||
try: | ||
labels = DatetimeIndex(labels) | ||
# need to set here because we changed the index | ||
if fastpath: | ||
self._mgr.set_axis(axis, labels) | ||
except (tslibs.OutOfBoundsDatetime, ValueError): | ||
# labels may exceeds datetime bounds, | ||
# or not be a DatetimeIndex | ||
pass | ||
if labels._is_all_dates: | ||
|
||
deep_labels = labels | ||
if isinstance(labels, CategoricalIndex): | ||
deep_labels = labels.categories | ||
|
||
if not isinstance( | ||
deep_labels, (DatetimeIndex, PeriodIndex, TimedeltaIndex) | ||
): | ||
try: | ||
labels = DatetimeIndex(labels) | ||
# need to set here because we changed the index | ||
if fastpath: | ||
self._mgr.set_axis(axis, labels) | ||
except (tslibs.OutOfBoundsDatetime, ValueError): | ||
# labels may exceeds datetime bounds, | ||
# or not be a DatetimeIndex | ||
pass | ||
|
||
object.__setattr__(self, "_index", labels) | ||
if not fastpath: | ||
|
Uh oh!
There was an error while loading. Please reload this page.