This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
import numpy as np | |
df = pd.DataFrame({'a':range(10),'b':range(10,20),'c':np.zeros(10)}) # data | |
condition = np.where( (df.a > 5) & (df.b > 17) )[0] # return an array of row indices that match the condition | |
df.loc[df.index[condition],'c'] = 100 # Update the selected rows in column c |