Home > database >  Adding a dictionary to a DataFrame
Adding a dictionary to a DataFrame

Time:11-17

So I way trying to make a simple password manager using python and I got a problem. I cannot add a dictionary to a DataFrame. It gives me - "Empty DataFrame"

import pandas as pd

start = int(input('Welcome to the password manager! Type in pass:'))
password = 12345
while True:
    if start == password:
        table = pd.DataFrame(columns=['Service', 'Login', 'Password'],)
        service = input('Service name:')
        login = input('Login:')
        passw = input('Password:')
        row = {'Service': service, 'Login': login, 'Password': passw}
        table.append(row, ignore_index=True)
        print(table.head(3))
        break
    else:
        print('Access denied')
        break

CodePudding user response:

Firstly, there is not need for the while loop while using break it have no sense.

Secondly, for your code you forgot to assign the value to the result

table = table.append(row, ignore_index=True)
  • Related