In [9]:
# Import the pandas library and assign an alias to it 
import pandas as pd
In [10]:
# Create a DataFrame by passing a dictionary to the constructor of pd.DataFrame
account_info = pd.DataFrame({"name": ["Bob", "Mary", "Mita"],
                             "account": [123846, 123972, 347209],
                             "balance": [123, 3972, 7209]})
In [11]:
# Access rows data by the key of the column
account_info["name"]
Out[11]:
0     Bob
1    Mary
2    Mita
Name: name, dtype: object
In [4]:
# Access the whole data in the DataFrame
account_info
Out[4]:
name account balance
0 Bob 123846 123
1 Mary 123972 3972
2 Mita 347209 7209
In [12]:
# Update rows for the column name
account_info["name"] = ["Smith", "Jane", "Patel"]
In [6]:
account_info
Out[6]:
name account balance
0 Smith 123846 123
1 Jane 123972 3972
2 Patel 347209 7209
In [13]:
# Create a sub-DataFrame
account_info[["name", "balance"]]
Out[13]:
name balance
0 Smith 123
1 Jane 3972
2 Patel 7209
In [8]:
account_info
Out[8]:
name account balance
0 Smith 123846 123
1 Jane 123972 3972
2 Patel 347209 7209
In [ ]: