-1

I have tried merging with Pandas merge, however, as the length of data is different, merge function is broadcasting the data even when using a key. The following line of code has been used.

dt = pd.merge(df,data[['Post ID','Sentiment']], on = 'Post ID')

Using join produces the following:

df.join(data[['Post ID','Sentiment']],on = 'Post ID')

You are trying to merge on object and int64 columns. If you wish to proceed you should use pd.concat

  • 1
    You should provide a [mcve]. – jpp Jun 26 '18 at 08:35
  • Possible duplicate of [Trying to merge 2 dataframes but get ValueError](https://stackoverflow.com/questions/50649853/trying-to-merge-2-dataframes-but-get-valueerror) – Rhesous Jun 28 '18 at 08:13

1 Answers1

0

This error means that in one of your database, Post ID is an objectand in the other one it is defined as int. You need to convert them so they have the same type, for instance by doing :

df['Post ID'] = df['Post ID'].astype(int)
eyllanesc
  • 235,170
  • 19
  • 170
  • 241
Rhesous
  • 984
  • 6
  • 12