Skip to content

ENH: allow axis argument to append / move append code to generic.py (GH8295) #8337

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
wants to merge 4 commits into from
Closed

ENH: allow axis argument to append / move append code to generic.py (GH8295) #8337

wants to merge 4 commits into from

Conversation

htkm
Copy link

@htkm htkm commented Sep 21, 2014

closes #8295

  • Extract append method in frame.py into generic.py
    • I left the original code just commented.
  • Extract test cases in test_frame.py into test_generic.py
  • Extract test cases in test_series.py into test_generic.py
  • Specific test case for testing axis=1 in test_generic.py
  • Generic method append in generic.py
  • NotImeplementedError for Panel
  • Docstring for generic append
  • Release note
  • Documentation
  • CI pass

One more thing, could Series.append use axis=1 as well ?

pd.Series([1,2,3]).append(pd.Series(['a','b','c']), axis=1)

   0  1
0  1  a
1  2  b
2  3  c

# just like below
# pd.concat((pd.Series([1,2,3]), pd.Series(['a','b','c'])), axis=1)

It would be awesome if I could get your guidance to close this issue under the project's convention. Thank you !

…GH8295)

`append` moved from frame.py to generic.py with docs commented.

test cases for DataFrame.append moved from tests_frame.py to tests_generic.py #1

test cases for DataFrame.append moved from tests_frame.py to tests_generic.py #2

test cases for DataFrame.append moved from tests_frame.py to tests_generic.py #3

test cases for Series.append moved from tests_series.py to tests_generic.py

`append` in generic.py passes `axis` argument. And added corresponding test case
@jreback jreback added API Design Reshaping Concat, Merge/Join, Stack/Unstack, Explode labels Sep 21, 2014
verify_integrity=verify_integrity)
# def append(self, other, ignore_index=False, verify_integrity=False):
# """
# Append columns of other to end of this frame's columns and index,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

simply delete this code (rather than comment it out).

@jreback
Copy link
Contributor

jreback commented Sep 21, 2014

@htkm the answer to your question is yes, Series.append CAN take axis=1 to create a frame. Though that would need some separate tests.

@htkm
Copy link
Author

htkm commented Sep 22, 2014

I made some changes to follow your advice. And for generic DataFrame.append with axis=1, I found something interesting when I do the same thing by pd.concat with axis=1.

df = pd.DataFrame(np.random.randn(2,2), columns=list('AB'))
sr = pd.Series(range(2), index=[0,10], name='SR')

pd.concat((df, sr), axis=1)
           A         B  SR
0   0.376365 -0.830094   0
1   0.765837  1.001402 NaN
10       NaN       NaN   1

df.append(sr.to_frame(), axis=1)
           A         B  SR
0   0.376365 -0.830094   0
1   0.765837  1.001402 NaN
10       NaN       NaN   1

df.append(sr, axis=1)
           A         B   0  10   A   B   0  10
0   0.376365 -0.830094 NaN NaN NaN NaN NaN NaN
1   0.765837  1.001402 NaN NaN NaN NaN NaN NaN
SR       NaN       NaN NaN NaN NaN NaN   0   1

I think df.append(sr, axis=1) seems to return unexpected results. Do you think append method in generic.py should be modified to make it work like pd.concat ? Thank you.

@jreback
Copy link
Contributor

jreback commented Sep 23, 2014

@htkm I think you are right, the last df.append(sr,axis=1) should be equivalent to df.append(sr.to_frame(),axis=1)

@jreback
Copy link
Contributor

jreback commented Jan 13, 2015

can you rebase this on master and see where it is?

@jreback jreback added this to the 0.16.0 milestone Jan 13, 2015
@jreback jreback modified the milestones: 0.16.0, Next Major Release Mar 3, 2015
@jreback
Copy link
Contributor

jreback commented May 9, 2015

closing pls reopen if/when updated

@jreback jreback closed this May 9, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API Design Reshaping Concat, Merge/Join, Stack/Unstack, Explode
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ENH: allow axis argument to append / move append code to generic.py
2 participants