Skip to content

Series(series) discards name attribute #1578

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

Closed
njsmith opened this issue Jul 7, 2012 · 4 comments
Closed

Series(series) discards name attribute #1578

njsmith opened this issue Jul 7, 2012 · 4 comments

Comments

@njsmith
Copy link

njsmith commented Jul 7, 2012

Data and index are preserved, but not name:

>>> import pandas
>>> pandas.__version__
'0.8.0'
>>> s = pandas.Series([1, 2, 3], index=[4, 5, 6], name="NAME")
>>> s
4    1
5    2
6    3
Name: NAME
>>> pandas.Series(s)
4    1
5    2
6    3
@njsmith
Copy link
Author

njsmith commented Jul 7, 2012

Heh. Github doesn't seem to notify for commits added to a bug, but I noticed that you were working on this because I was just watching my pandas integration tests run on travis, and saw it running on the next virtual buildslave over...

@changhiskhan
Copy link
Contributor

ha, didn't know that, that's interesting.

@njsmith
Copy link
Author

njsmith commented Jul 7, 2012

Also, thanks :-)

@changhiskhan
Copy link
Contributor

thanks for the feedback =0)

algitbot pushed a commit to alpinelinux/aports that referenced this issue Nov 5, 2024
Update numpy array copy references for numpy 2.0 compatibility to fix
failed tests.

```
a = [1, 2, 3], copy = False, dtype = None, subok = False

    def asarray_or_pandas(a, copy=False, dtype=None, subok=False):
        if have_pandas:
            if isinstance(a, (pandas.Series, pandas.DataFrame)):
                # The .name attribute on Series is discarded when passing through
                # the constructor:
                #   pandas-dev/pandas#1578
                extra_args = {}
                if hasattr(a, "name"):
                    extra_args["name"] = a.name
                return a.__class__(a, copy=copy, dtype=dtype, **extra_args)
>       return np.array(a, copy=copy, dtype=dtype, subok=subok)
E       ValueError: Unable to avoid copy while creating an array as requested.
E       If using `np.array(obj, copy=False)` replace it with `np.asarray(obj)` to allow a copy when needed (no behavior change in NumPy 1.x).
E       For more details, see https://numpy.org/devdocs/numpy_2_0_migration_guide.html#adapting-to-changes-in-the-copy-keyword.

patsy/util.py:67: ValueError
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants