I have a pd.Dataframe with 3 columns [str_name,target,sec_id]
Currently all values of the col sec_id are -1. I want to sample ~100 rows and replace the values of this column to NaN.
Following is the code
sample_rows = new_pd[new_pd['sec_id'] == -1].sample(n=130)
sample_rows.sec_id = float('NaN')
new_pd.update(sample_rows)
Consequently, I want to drop these from the new_pd. So, I did following
new_pd = new_pd[new_pd['sec_id'].notna()]
But it seems like the number of rows of the new_pd is still the same. Any idea whats happening here ?
Aucun commentaire:
Enregistrer un commentaire