• +91 9723535972
  • info@interviewmaterial.com

Data Science Interview Questions and Answers

Question - How to keep only the top 2 most frequent values as it is and replace everything else as ‘Other’?

Answer -

"s = pd.Series(np.random.randint(1, 5, [12]))
print(s.value_counts())
s[~s.isin(ser.value_counts().index[:2])] = 'Other'
s"

Comment(S)

Show all Coment

Leave a Comment




NCERT Solutions

 

Share your email for latest updates

Name:
Email:

Our partners