I am using Pandas to merge two dataframes obtained from Psychopy.
y = ["key_resp_0.keys", "key_resp_0.rt"] #some columns I want in my final dataframe
df = pd.DataFrame(myData)
columns = df.columns.values.tolist()
df2 = df.reindex(columns = y, fill_value='')
df3 = pd.merge(df2,df)
This is the error I get:
type object argument after * must be an iterable, not itertools.imap
I checked what type of dataframes I have:
print(type(df))
print(type(df2))
This is the result:
<class 'pandas.core.frame.DataFrame'> #df
<class 'pandas.core.frame.DataFrame'> #df2
Following some info found in other posts, I also tried to convert df
and df2
into tuples and then doing the merge
.
df = df.apply(tuple)
df2 = df2.apply(tuple)
df3 = pd.merge(df2,df)
Then I get a different error
can not merge DataFrame with instance of type <class 'pandas.core.series.Series'>
Do you know what could be a way to merge these two dataframes?
I think I managed to find a solution.
In my dataframe df
there was a possibly empty string (when opening df
as a .csv file, one cell contained only []
). Now I am assigning to that cell a value of zero and the merge function seems to work properly.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.