Skip to content

BUG: Append the empty frame with columns, #3121 #3184

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

Merged
merged 2 commits into from
Apr 3, 2013

Conversation

waitingkuo
Copy link
Contributor

From issue3121

Bug

In [1]: import pandas as pd

In [2]: df1 = pd.DataFrame(columns=['test'])

In [3]: df2 = pd.DataFrame()

In [4]: df1.append(df2)

ValueError: need at least one array to concatenate

Reason

numpy cannot concatenate nothing:

In [10]: import numpy as np

In [11]: np.concatenate([])

ValueError: need at least one array to concatenate

Fix

Return an empty numpy array if we find that the arrays to be concatenated are empty

# return the empty np array, if nothing to concatenate, #3121
    if not to_concat: return np.array([], dtype=object)

Test

Test case test_append_empty_frame is added in test_frame.py

@hayd
Copy link
Contributor

hayd commented Apr 1, 2013

This bug fix looks great, but what are the other datetime tests at the end of the file? (or am I missing something?)

@waitingkuo
Copy link
Contributor Author

Sorry for accidentally adding some duplicated test cases. Have removed them.

@hayd
Copy link
Contributor

hayd commented Apr 3, 2013

Awesome!

hayd added a commit that referenced this pull request Apr 3, 2013
BUG: Append the empty frame with columns, #3121
@hayd hayd merged commit f6e84c5 into pandas-dev:master Apr 3, 2013
@waitingkuo waitingkuo deleted the fix-append-empty-frame branch April 3, 2013 08:43
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

Successfully merging this pull request may close these issues.

2 participants