-2

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?

OcMaRUS
  • 329
  • 3
  • 13
  • 1
    `print(user_profile)`? –  Oct 06 '20 at 13:14
  • yes, it prints but different format. I would prefer default formating. simple print command types w/o formating at all. – OcMaRUS Oct 07 '20 at 07:17
  • What I meant was you did not do any printing at all except for the one in the else block. You also need to show what you want the output to look like. –  Oct 07 '20 at 09:44
  • In juniper book if you write the name of dataframe, it will print columns name and data. You don't need to use print function. What i did in my code: ```user_profile.head as it is one row dataframe, it prints as expected. Solved :) – OcMaRUS Oct 07 '20 at 14:35

1 Answers1

0

as it is one row dataframe, i wrote:

user_profile.head

and got expected

OcMaRUS
  • 329
  • 3
  • 13