i've searched thoroughly hours answer this, unfortunately haven't been able find anything.
i have csv file looks on picture.
what want is, example, create new column every row 0, except if month==1 and day>11. did similar, made new column rows=0 when hour>8 , hour<20, , rest ones:
datatest['day_or_night'] = 0 datatest['day_or_night'][datatest['hour'] < 8] = 1 datatest['day_or_night'][datatest['hour'] > 20] = 1
any appreciated!
try this:
df['new'] = np.where((df.month==1) & (df.day>11), 1 0)
Comments
Post a Comment