Skip to content

Instantly share code, notes, and snippets.

@AayushSameerShah
Last active May 29, 2021 11:43
Show Gist options
  • Save AayushSameerShah/69aa327d583ce6c841172671830e2868 to your computer and use it in GitHub Desktop.
Save AayushSameerShah/69aa327d583ce6c841172671830e2868 to your computer and use it in GitHub Desktop.
'''There can be a situation while cleaning the data
you might want ot replace one dataframe's value on
certain indices with other df's values (usually cl-
eared ones) based on the index - This MIGHT help.
2 Solutions.'''
# 1. Great - Almost all time will work
df.col_to_change.update(df.col_new_value)
' As both are Series - this will work! '
# 2. Other work around
df1['col_to_replace'].fillna(df2['all_values_col'])
# The point is - You can use ↑ in fillna!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment