3 Replies - 151 Views - Last Post: 12 November 2019 - 02:35 AM Rate Topic: -----

#1 sx200n   User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 57
  • Joined: 07-July 17

How to compare two dataframes columns for duplicate values

Posted 11 November 2019 - 07:54 AM

Hello,

I need to complete a part of a university assignment.

I am just after some pointers...

They have given me two dataframes of sales data. Both dataframes have a column titled 'country' and I need to return a list of values that can be found in both dataframes in the 'country' column only.

I have tried to use the duplicate and intersection methods as well as the merge method, but neither work and I think it is because the two dataframes have differing numbers of rows?

The merge function worked for me but returned too few matches as I belive it is trying to match on value AND index. But for this task the index is irrelevant as I just need to return a list of values found in both dataframes.

I cannot add any code or attachments I'm afraid as I am on my mobile, but thought I would ask for pointers and at least to find out if i can use either the merge, intersection or duplicate methods given that the number of rows differ and therefore both columns have differ index lengths.

Any assistance would be greatly appreciated as the number of marks for this task is very low which makes me think the solution Should be very simple.

Is This A Good Question/Topic? 0
  • +

Replies To: How to compare two dataframes columns for duplicate values

#2 andrewsw   User is offline

  • never lube your breaks
  • member icon

Reputation: 6823
  • View blog
  • Posts: 28,277
  • Joined: 12-December 12

Re: How to compare two dataframes columns for duplicate values

Posted 11 November 2019 - 08:00 AM

Moved out of discussion lounge, you are asking for help, not introducing a broader topic for discussion. You should understand this by now.

You should also provide some code when you are not on your mobile.
Was This Post Helpful? 0
  • +
  • -

#3 sx200n   User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 57
  • Joined: 07-July 17

Re: How to compare two dataframes columns for duplicate values

Posted 11 November 2019 - 08:02 AM

andrewsw - thanks.

Hadn't realised I had placed it there. I blame the tiny buttons on my mobile.

Would also make sense as to why I couldn't find my initial question of this that I posted a few weeks ago 😕
Was This Post Helpful? 0
  • +
  • -

#4 sx200n   User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 57
  • Joined: 07-July 17

Re: How to compare two dataframes columns for duplicate values

Posted 12 November 2019 - 02:35 AM

Please ignore this post as I have now solved it.

I have managed to get the intersection method working once cast as sets.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1