Try to search your question here, if you can't find : Ask Any Question Now ?

Removing rows from data frames with multiple conditions using a loop

HomeCategory: stackoverflowRemoving rows from data frames with multiple conditions using a loop
Avatarsourav asked 4 weeks ago

I have a data frame that currently looks like this:

     ID    Freq
     A     10
     B     
     A
     G     6
     B     11
     C     6
     C     7
     D     
     E

The data frame that I am after is this:

     ID    Freq
     A     10
     G     6
     B     11
     C     6
     C     7
     D     
     E

I am currently trying to write a loop that identifies duplicates in the ID column and then removes the duplicate row with the blank Freq value. If there are duplicate IDs where both have values in Freq, I don’t want to delete them. Where do I begin with this? Would I use the duplicated function to identify the duplicates?

EDIT: Edited to add some rows to show that I want to retain a blank Freq value if the ID is not a duplicate.

1 Answers
Best Answer
Avatarnaveen answered 4 weeks ago
Your Answer

17 + 16 =

Popular Tags

WP Facebook Auto Publish Powered By : XYZScripts.com