Skip to content
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

pd.concat with Dictionary argument throws ValueError #1631

Closed
vidapura opened this issue Jun 18, 2020 · 2 comments · Fixed by #1795
Closed

pd.concat with Dictionary argument throws ValueError #1631

vidapura opened this issue Jun 18, 2020 · 2 comments · Fixed by #1795
Assignees
Labels
bug 🦗 Something isn't working
Milestone

Comments

@vidapura
Copy link

Hi,
Just installed modin for the first time.. and I'm failing at the first hurdle.
Could anyone please take a look and tell me if they can spot something obvious I'm doing wrong?
I'm using a macbook with 10.15.4 of the OS.
python 3

Installed modin using:

pip install modin[ray]

Now I'm trying to run code that worked with pandas:

import modin.pandas as pd
df_wave1 = pd.read_csv("Survey_1.csv")
df_wave2 = pd.read_csv("Survey_Cleaned_2.csv")
df_wave3 = pd.read_csv("Survey_Cleaned_3.csv")

surveys = {'1': df_wave1, '2': df_wave2, '3': df_wave3, }

df_all = pd.concat(surveys,  sort=False)

But I'm getting the error:

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-1-0ed75db51eaa> in <module>
      6 surveys = {'1': df_wave1, '2': df_wave2, '3': df_wave3, }
      7 
----> 8 df_all = pd.concat(surveys,  sort=False)

~/.virtualenvs/learningenv/lib/python3.7/site-packages/modin/pandas/concat.py in concat(objs, axis, join, ignore_index, keys, levels, names, verify_integrity, sort, copy)
     64             "and modin.pandas.DataFrame objs are "
     65             "valid",
---> 66             type(type_check),
     67         )
     68     all_series = all(isinstance(obj, Series) for obj in objs)

ValueError: ('cannot concatenate object of type "{0}"; only pandas.Series, pandas.DataFrame, and modin.pandas.DataFrame objs are valid', <class 'str'>)

I don't have pandas imported into the notebook.
I have restarted the kernel etc.

Any help would be greatly appreciated.
Thanks

@vidapura vidapura added the question ❓ Questions about Modin label Jun 18, 2020
@devin-petersohn devin-petersohn added bug 🦗 Something isn't working and removed question ❓ Questions about Modin labels Jun 18, 2020
@devin-petersohn devin-petersohn added this to the 0.7.4 milestone Jun 18, 2020
@devin-petersohn
Copy link
Collaborator

Hi @vidapura, thanks for posting! This looks like a bug in Modin related to dictionary concatenation. We will get this fixed.

As a temporary workaround, you can slightly change your code to this:

import modin.pandas as pd
df_wave1 = pd.read_csv("Survey_1.csv")
df_wave2 = pd.read_csv("Survey_Cleaned_2.csv")
df_wave3 = pd.read_csv("Survey_Cleaned_3.csv")

# surveys = {'1': df_wave1, '2': df_wave2, '3': df_wave3, }
df_wave1.index = pd.MultiIndex.from_tuples([("1", i) for i in df_wave1.index])
df_wave2.index = pd.MultiIndex.from_tuples([("2", i) for i in df_wave2.index])
df_wave3.index = pd.MultiIndex.from_tuples([("3", i) for i in df_wave3.index])
surveys = [df_wave1, df_wave2, df_wave3]

df_all = pd.concat(surveys,  sort=False)

@devin-petersohn devin-petersohn changed the title ValueError: ('cannot concatenate object of type "{0}"; only pandas.Series, pandas.DataFrame, and modin.pandas.DataFrame objs are valid', <class 'str'>) pd.concat with Dictionary argument throws ValueError Jun 18, 2020
@vidapura
Copy link
Author

Ahh brilliant!
Thanks @devin-petersohn !
I'll continue on with the experiment now and see if the rest of the code works with modin.
Thanks again.

@devin-petersohn devin-petersohn self-assigned this Jul 24, 2020
devin-petersohn added a commit to devin-petersohn/modin that referenced this issue Jul 24, 2020
Signed-off-by: Devin Petersohn <devin.petersohn@gmail.com>
aregm pushed a commit that referenced this issue Jul 24, 2020
Signed-off-by: Devin Petersohn <devin.petersohn@gmail.com>
aregm pushed a commit to aregm/modin that referenced this issue Sep 16, 2020
…din-project#1795)

Signed-off-by: Devin Petersohn <devin.petersohn@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🦗 Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants