I have a pandas series that looks like this, extracted on querying a dataframe.
t_loc= 312 False 231 True 324 True 286 False 123 False 340 True I want only the indices that have 'True' boolean value.
I tried t_loc.index gives me all the indices. t_loc['True'] or t_loc[True] are both futile. Need help. Also, I need to update these locations with a single number if True. How can I update a column in a dataframe given the location numbers ?
Desired O/P: [231,324,340]
Need to update eg. df[col1] @ 231.. is it df[col1].loc[231] ? How to specify multiple locations? Can we pass the entire list since I need to update it with only one value for all the locations ?
t_loc.index[t_loc]df.loc[t_loc, 'col1'] = 40.