-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
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
concat doesn't work with mixed Series/DataFrames #2385
Comments
Well that's not very helpful. Should be improved at some point |
Am I right in saying these give better errors in dev?
|
I like the first one, prob should catch the error in concat and put up a better message for the 2nd one though.... |
Agreed. |
ok...let's move to 0.12 then... |
It's not the incorrect error which is the problem, but the fact that an error is thrown at all. This makes it difficult/tedious to write generic code that works whether or not the input is a DataFrame or a TimeSeries. In this case the TimeSeries should be treated as a DataFrame with one column where the column label is taken from the TimeSeries name. It the axis parameter was 0 then the TimeSeries should be treated as a DataFrame with one row where the row label is taken from the TimeSeries name. |
@dhirschfeld I think we will have a detailed look at this, but nothing is stopping you from pre-conditining, e.g.
The DataFrame constructor does exactly what you want for a series with axis=1, and passed thru a DataFrame |
I also stumbled on this, but I saw there is already this issue for it. I think in current master it is still very confusing. An example (with the series being a column from a dataframe, full example: http://nbviewer.ipython.org/5868420/bug_pandas-concat-series.ipynb ):
I think at the moment it is not clear from the docs that this is not allowed (mixing dataframes with series/columns), and when you do it, you don't get a very informative error message. |
So should work like this:
|
series must have a name FYI (otherwise needs to raise) |
atm it's a bit sketchy with name:
Not sure should always raise w/o name. |
@hayd that's the problem, it "works" but really should not (as its assigned as if the column index doesn't exist). I would just be careful about it, maybe only allowing it if |
not exactly the same situation, but |
Was suggestion above that these should be the same (not quite there in master): #2385 (comment)
open as sep issue? Definitely looking good though! |
I'll add them as tests |
@hayd It seems that your above example should work, but how does I could put a note that all alignment would be column-wise. (also maybe could add a keywork, |
concat thows an
AssertionError
when passed a ciollection of mixed Series and Dataframes e.g.The text was updated successfully, but these errors were encountered: