Skip to content

Commit

Permalink
Update nsfg2.py
Browse files Browse the repository at this point in the history
Fixed the following:
---
nsfg2.py:57: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
`  df.birthwgt_lb1[df.birthwgt_lb1 > 20] = np.nan`
  • Loading branch information
yongduek committed Apr 10, 2018
1 parent 414d810 commit 54bd293
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion code/nsfg2.py
Expand Up @@ -54,7 +54,7 @@ def CleanFemPreg(df):

# birthwgt_lb contains at least one bogus value (51 lbs)
# replace with NaN
df.birthwgt_lb1[df.birthwgt_lb1 > 20] = np.nan
df.loc[df.birthwgt_lb1 > 20, 'birthwgt_lb1'] = np.nan

# replace 'not ascertained', 'refused', 'don't know' with NaN
na_vals = [97, 98, 99]
Expand Down

0 comments on commit 54bd293

Please sign in to comment.