Solving Python Data Analysis Interview Questions - Apple

Поделиться
HTML-код
  • Опубликовано: 15 сен 2024
  • In this series, I will be solving python data analysis interview questions in Stratascratch. In this particular video, I'm solving Google's interview question.
    If you have any questions or feedback regarding this content, please let me know in the comments or you can contact me directly via email: makunadata@gmail.com
    My solution to the problem:
    Apple product counts:
    df = playbook_events.merge(playbook_users, on = 'user_id', how = 'left')[['user_id','device', 'language']]
    df['is_apple'] = df['device'].apply(lambda x: x.lower() in ['macbook pro', 'iphone 5s', 'ipad air'])
    apple = df[df['is_apple']]
    apple = apple.drop_duplicates('user_id')
    apple = apple.groupby('language', as_index = False)['device'].count()
    df = df.drop_duplicates('user_id')
    df = df.groupby('language', as_index = False)['device'].count()
    df = df.merge(apple, on = 'language', how = 'left', suffixes = ['_total', '_apple']).fillna(0)
    df.sort_values('device_total', ascending = False)
    Try out Stratascratch: stratascratch....

Комментарии •