Skip to content

DOC: pandas.Series(data=None, index=None, dtype=None, name=None, copy=False, fastpath=False) #41423

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
Lokeshrathi opened this issue May 11, 2021 · 4 comments · Fixed by #41514
Assignees
Milestone

Comments

@Lokeshrathi
Copy link

No proper information on "copy" is present under Documentation

@Lokeshrathi Lokeshrathi added Docs Needs Triage Issue that has not been reviewed by a pandas team member labels May 11, 2021
@attack68 attack68 added good first issue and removed Needs Triage Issue that has not been reviewed by a pandas team member labels May 11, 2021
@attack68
Copy link
Contributor

The parameter is documented. Although I agree it could be made clearer.

Essentially since copy=False by default the memory location for the values is shared, although this only works for certain objects, as to whether the Series presents a copy or a view of the data:

r = [1,2]
s = pd.Series(r)
t = pd.Series(s)
t.iloc[0] = 999
print(r)
print(s)
print(t)

[1, 2]
0    999
1      2
dtype: int64
0    999
1      2
dtype: int64
r = np.array([1,2])
s = pd.Series(r)
t = pd.Series(s)
t.iloc[0] = 999
print(r)
print(s)
print(t)

[999   2]
0    999
1      2
dtype: int64
0    999
1      2
dtype: int64

@mdhsieh
Copy link
Contributor

mdhsieh commented May 14, 2021

I'd like to help make this clearer, by adding the above example and explanation to the copy documentation.

@mdhsieh
Copy link
Contributor

mdhsieh commented May 14, 2021

take

mdhsieh added a commit to mdhsieh/pandas that referenced this issue May 14, 2021
mdhsieh added a commit to mdhsieh/pandas that referenced this issue May 16, 2021
…v#41423).

Original data unchanged when Series is a Copy,
but original data is changed when Series is a View.
@mdhsieh
Copy link
Contributor

mdhsieh commented May 16, 2021

I tried making changes to the Series main section instead.

mdhsieh added a commit to mdhsieh/pandas that referenced this issue May 16, 2021
…v#41423).

After building documentation, found the code examples were not displayed correctly.
Added newlines and rebuilt to fix.
mdhsieh added a commit to mdhsieh/pandas that referenced this issue May 18, 2021
…1423).

Remove return, replace with has.
Remove array, replace with list.
Fix array spacing to match other Series examples.
Replace long param info with only affects sentence, based off DataFrame documentation.
Reword example explanation.
Change numpy.array to 1d ndarray to match other documentation, like DataFrame.
mdhsieh added a commit to mdhsieh/pandas that referenced this issue May 18, 2021
Remove whitespace on blank lines and line break sentences to avoid style errors.
Previous commit had 1 failing check.
mdhsieh added a commit to mdhsieh/pandas that referenced this issue May 18, 2021
…#41423).

Remove whitespace on blank lines and line break sentences to avoid style errors.
Previous commit had 1 failing check.
@jreback jreback added this to the 1.3 milestone May 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants