as I already mentioned in the title.
For example, I have a dataframe in python like this :
dataframe = pd.DataFrame({‘Energy Consumption’: [20, 21, 19, 18, 25, 40, 18]})
If I want to multiply a number such as 0.3 on row index 3 to the end. How can I do that by the shortest operation time.
Thanks in advance.
>Solution :
You can do loc(assume the index is from 0 to n-1 , if not df.reset_index(drop=True, inplace=True) before below)
dataframe.loc[2:,'Energy Consumption'] *= 0.3
dataframe
Energy Consumption
0 20.0
1 21.0
2 5.7
3 5.4
4 7.5
5 12.0
6 5.4