Reputation: 101
I have a data file, when I import it into pandas I have
Index DATE_TIME Parameter
0 13/1/2016 03.45 0
1 13/1/2016 04.45 13
2 13/1/2016 05.00 27.6
3 13/1/2016 06.45 0
4 13/1/2016 07.00 1
I want to delete the first 1000 entries from the parameters column without deleting the DATE_TIME column, leaving the top part of parameter blank.
This is probably really simple but I can't seem to find the right command.
Thanks for any help.
Upvotes: 1
Views: 363
Reputation: 394041
You can do this using loc
and passing the first N entries from the index:
In [120]:
df.loc[df.index[:2], 'Parameter'] = np.NaN
df
Out[120]:
Index DATE_TIME Parameter
0 13/1/2016 3.45 NaN
1 13/1/2016 4.45 NaN
2 13/1/2016 5.00 27.6
3 13/1/2016 6.45 0.0
4 13/1/2016 7.00 1.0
This will operate on a view rather than a copy
You assign whatever value you wish, here I assign NaN
Upvotes: 2