-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
pd.eval
: Series
names are now preserved even for "numexpr"
engine.
#58437
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
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 |
---|---|---|
|
@@ -160,19 +160,24 @@ def align_terms(terms): | |
# can't iterate so it must just be a constant or single variable | ||
if isinstance(terms.value, (ABCSeries, ABCDataFrame)): | ||
typ = type(terms.value) | ||
return typ, _zip_axes_from_type(typ, terms.value.axes) | ||
return np.result_type(terms.type), None | ||
name = terms.value.name if isinstance(terms.value, ABCSeries) else None | ||
return typ, _zip_axes_from_type(typ, terms.value.axes), name | ||
return np.result_type(terms.type), None, None | ||
|
||
# if all resolved variables are numeric scalars | ||
if all(term.is_scalar for term in terms): | ||
return result_type_many(*(term.value for term in terms)).type, None | ||
return result_type_many(*(term.value for term in terms)).type, None, None | ||
|
||
# if all input series have a common name, propagate it to the returned series | ||
names = {term.value.name for term in terms if isinstance(term.value, ABCSeries)} | ||
name = next(iter(names)) if len(names) == 1 else None | ||
domsmrz marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
# perform the main alignment | ||
typ, axes = _align_core(terms) | ||
return typ, axes | ||
return typ, axes, name | ||
|
||
|
||
def reconstruct_object(typ, obj, axes, dtype): | ||
def reconstruct_object(typ, obj, axes, dtype, name): | ||
""" | ||
Reconstruct an object given its type, raw value, and possibly empty | ||
(None) axes. | ||
|
@@ -200,7 +205,9 @@ def reconstruct_object(typ, obj, axes, dtype): | |
res_t = np.result_type(obj.dtype, dtype) | ||
|
||
if not isinstance(typ, partial) and issubclass(typ, PandasObject): | ||
return typ(obj, dtype=res_t, **axes) | ||
if name is None: | ||
return typ(obj, dtype=res_t, **axes) | ||
return typ(obj, dtype=res_t, name=name, **axes) | ||
Comment on lines
+209
to
+210
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. Shouldn't 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. Unfortunately no. In some cases |
||
|
||
# special case for pathological things like ~True/~False | ||
if hasattr(res_t, "type") and typ == np.bool_ and res_t != np.bool_: | ||
|
Uh oh!
There was an error while loading. Please reload this page.