Embark on a journey of knowledge! Take the quiz and earn valuable credits.
Take A QuizChallenge yourself and boost your learning! Start the quiz now to earn credits.
Take A QuizUnlock your potential! Begin the quiz, answer questions, and accumulate credits along the way.
Take A QuizGeneral Tech Technology & Software 2 years ago
Posted on 16 Aug 2022, this text provides information on Technology & Software related to General Tech. Please note that while accuracy is prioritized, the data presented might not be entirely correct or up-to-date. This information is offered for general knowledge and informational purposes only, and should not be considered as a substitute for professional advice.
I come up with this solution by using random.choice
import random
s=df1.groupby('Area').Company.apply(list).reindex(df.Area).apply(lambda x :random.choice(x) )
s.index=df.index
df.Company=df.Company.fillna(s)
df
Out[200]:
index Company Area
0 0 Google Technology
1 1 CocaCola Drinks
2 2 CocaCola Drinks
3 3 Apple Technology
4 4 Google Technology
5 5 Gatorade Drinks
6 6 Dell Technology
7 7 Apple Technology
8 8 CocaCola Drinks
9 9 Pepsi Drinks
10 10 Google Technology
No matter what stage you're at in your education or career, TuteeHub will help you reach the next level that you're aiming for. Simply,Choose a subject/topic and get started in self-paced practice sessions to improve your knowledge and scores.
General Tech 10 Answers
General Tech 7 Answers
General Tech 3 Answers
General Tech 9 Answers
Ready to take your education and career to the next level? Register today and join our growing community of learners and professionals.
manpreet
Best Answer
2 years ago
I have a DataFrame with millon of rows and a lot of NaN values. Some example:
My idea is to fill Companies NaN values with one of the 2 most common values for its Area.
From example: If the most frequent Companies in Technology area are Apple and Google, I Would like to fill the "df['Area'] == 'Technology'" NaN values with one of that values (randomly)
I've already created a Group By DataFrame with the most common values, it is something like this:
The result should be something like this:
I hope you can help me.
Thanks!!!