简体   繁体   中英

Iterate through values of dataframe

having a dataframe similar to the following

Country 00:00 00:30 01:00 ... 23:00 23:30
SWE     10    15    32        12    57
ITA     6     67    64        1     8
USA     92    13    45        8     32
...

How can I eg loop through the items of USA (and incrementing by 10) while checking if the index is not bigger than 13:30? eg

for x in df[df.Country == 'USA]:
    if x.index != '13:30':
        x =+ 10
    else:
        break

Thanks so much!

df.loc[df.Country == 'USA', '00:00':'13:30'] += 10

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM