Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask question.(5)

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

ITtutoria

ITtutoria Logo ITtutoria Logo

ITtutoria Navigation

  • Python
  • Java
  • Reactjs
  • JavaScript
  • R
  • PySpark
  • MYSQL
  • Pandas
  • QA
  • C++
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Python
  • Science
  • Java
  • JavaScript
  • Reactjs
  • Nodejs
  • Tools
  • QA
Home/ Questions/How to fix this error : can not merge dataframe with instance of type class 'pandas.core.series.series'.
Next
Answered
viviankuphal
  • 3
viviankuphal
Asked: June 20, 20222022-06-20T07:35:00+00:00 2022-06-20T07:35:00+00:00In: Error

How to fix this error : can not merge dataframe with instance of type class ‘pandas.core.series.series’.

  • 3

. Advertisement .

..3..

. Advertisement .

..4..

Hello everyone,  urgent situation!!!! I have 2 dataframes and I want to merge them together. However I have a trouble with the error “can not merge dataframe with instance of type <class ‘pandas.core.series.series’>”. My 2 dataframes look like this:

df1:

id name type currency
0 BTA.S Applewood Hard GBp
1 VOD.S Softwood Soft GBp
df2:

id
BTA.S 301.221525
VOD.S 213.791400

This is the program I want to run:

id name type currency price
0 BTA.S Applewood Hard GBp 301.221525
1 VOD.S Softwood Soft GBp 213.791400

However when I execute this method:

Result = df1.merge(df2[['*.S']], left_on='id', right_index=True)

I immediately received the following error message:

ValueError: can not merge DataFrame with instance of type <class 'pandas.core.series.Series'>

and when I’m running this:

Result = pd.concat([Df1, Df2], axis=1, ignore_index=True)

I received the following error message:

ValueError: labels ['type'] not contained in axis

I looked over the documentation and attempted to conduct the following procedure, but I’m not sure how to do it. Please help me find a way to fix this! Thank you very much !!!!    

can not merge dataframe with instance of typequestion
  • 1 1 Answer
  • 281 Views
  • 0 Followers
  • 0
Answer
Share
  • Facebook
  • Report

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Best Answer
    lyytutoria Expert
    2022-06-20T07:53:05+00:00Added an answer on June 20, 2022 at 7:53 am

    The cause:

    After studying your post I realized this is an error because you are leaving df2 of type pd.Series.

    Solution: 

    You must change df2 .to_frame() as .merge() needs a pd.DataFrame() input. 

    There are 3 ways for you to fix this error:

    df1.merge(df2[['*.S']].to_frame(), left_on='id', right_index=True)

    Or you can fix the error by this:

    df1.merge(df2.to_frame(), left_on='id', right_index=True)

    The last way is using pd.DataFrame.join() that allows a pd.Series. Hope my suggestions will help you. Good luck!!!

    • 2
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

Sidebar

Ask A Question
  • How to Split String by space in C++
  • How To Convert A Pandas DataFrame Column To A List
  • How to Replace Multiple Characters in A String in Python?
  • How To Remove Special Characters From String Python

Explore

  • Home
  • Tutorial

Footer

ITtutoria

ITtutoria

This website is user friendly and will facilitate transferring knowledge. It would be useful for a self-initiated learning process.

@ ITTutoria Co Ltd.

Tutorial

  • Home
  • Python
  • Science
  • Java
  • JavaScript
  • Reactjs
  • Nodejs
  • Tools
  • QA

Legal Stuff

  • About Us
  • Terms of Use
  • Privacy Policy
  • Contact Us

DMCA.com Protection Status

Help

  • Knowledge Base
  • Support

Follow

© 2022 Ittutoria. All Rights Reserved.

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.