import pandas as pd
一、创建DataFrame
1. 新建DataFrame
df = pd.DataFrame(data = [['Sisyphus', 'male', 'D'],
['Athena', 'female', 'B'],
['Zeus', 'male', 'A'],
['Hera', 'female', 'C'],
['Lucifer', 'male', 'B']],
columns = ['name', 'gender', 'rank'],
index = [0, 1, 2, 3, 4])
dic = {'name': ['Sisyphus', 'Athena', 'Zeus', 'Hera', 'Lucifer'],
'gender': ['male', 'female', 'male', 'female', 'male'],
'rank': ['D', 'B', 'A', 'C', 'B']}
df = pd.DataFrame(dic)
name | gender | rank | |
0 | Sisyphus | male |