简体   繁体   中英

no printing inside of "if" block

I have the code below in my juniper book. If user_payments is empty, i have message "no information" back. it works fine. But if rent_id is not empty, the information about user_profile (which must be printed inside of if: block, is not visible. If I add printing user_profile after if-else block and information is exist - it shows correctly.

if not user_payments.loc[:,'powerBankRentId'].empty:
    rent_id = user_payments.loc[:,'powerBankRentId'].values[0]
    user_profile['rent_id'] = rent_id
    user_last_rent = table_rents[table_rents['id'] == rent_id]
    user_profile.append(table_rents[table_rents['id'] == rent_id].loc[:,['station_name','createdAt','endAt']])
    user_profile['station_name'] = user_last_rent.loc[:,'station_name'].values[0]
    user_profile['start_rent']   = user_last_rent.loc[:,'createdAt'].values[0]
    user_profile['end_rent']     = user_last_rent.loc[:,'endAt'].values[0]
    user_profile # doesn't print anything
else:
    print('no information')

Can you give me an idea how i mush correct the code?

as it is one row dataframe, i wrote:

user_profile.head

and got expected

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