assume I have a dataframe. I would like to modify a list of rows with certain value.
For example, below is my dataframe.
df = pd.DataFrame({
"strings":["A", "B", "C", "D", "E"],
"value":["a", "b", "c", "d", "f"],
"price":["1", "2", "3", "4", "5"]})
And I want to replace all cells with '0' in row C, D, and E, which is like below. Rows = ['C', 'D', 'E']
df = pd.DataFrame({
"strings":["A", "B", "C", "D", "E"],
"value":["a", "b", "0", "0", "0"],
"price":["1", "2", "0", "0", "0"]})
I know we can achieve this by simply giving the rows' name and certain value, but as we have lots of rows to be modified, how could we do this more efficiently using pandas?
Anyone hint please?