I have a Dataframe df which columns are ['col_A' , 'col_B', 'col_C'] and it has 1000 rows.
I have also a series that has as index the names of the columns of the DataFrame and a value that is between 0 and 1000. For instance: s is the Serie as such:
Col_A 20
Col_B 0
Col_C 300
I would like to change the dataframe as:
df.iloc[0:20,0] = a certain value (column A)
I've tried slicing using a for loop but its taking too much time. is there a pandas function able to do this ?
My code is:
for i in range(0,3):
df.iloc[0:s.iloc[i]-1,i] = -1
In a general scope, I sometimes need to map a Series index to a Dataframe column but struggle to find a fast and less consuming method.
Thank you
scoming from.