Created
November 22, 2017 04:57
-
-
Save jaradc/aaf8177da4fa9e6d7c35394ae215a7d4 to your computer and use it in GitHub Desktop.
This is a good example of inplace not working as-expected
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
df = pd.DataFrame( | |
{'Label': [np.nan, np.nan, 'Label1', 'Label2'], | |
'URL': ['https://www.website.com/where-to-buy', | |
np.nan, np.nan, 'https://www.website.com/store'] | |
}, columns=['Label', 'URL']) | |
# this does not actually replace inplace! | |
df[['Label', 'URL']].fillna('', inplace=True) | |
# you have to assign it or use a dict | |
self.data.fillna({'Campaign': '', 'Final URL': ''}, inplace=True) | |
# or | |
df[['Label', 'URL']] = df[['Label', 'URL']].fillna('') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment