Updating column values in a specific row range in pandas

Viewed 1253

I am trying to update some of my values in my 'date' column within my panda's data frame.

Currently, my data looks like:

            Date

0      09/08/2019 20:00
1      10/08/2019 12:30
2      10/08/2019 15:00
3      10/08/2019 15:00
4      10/08/2019 15:00
5      10/08/2019 15:00
6      10/08/2019 17:30
7      11/08/2019 14:00
8      11/08/2019 14:00
9      11/08/2019 16:30
10     17/08/2019 12:30

I want to update rows 1 to 287 in this specific column with 'Part 1' and the remainder with part 2.

This is my current code:

 df3.loc[0:287, 'Date'].replace("Part 1", inplace=True)

Does anyone have any suggestions on how I could approach this?

1 Answers

To make it more pythonish:

df3.loc[1:288, 'Date'] = "Part 1"

df3.loc[288:, 'Date'] = "Part 2"
Related