仅供学习
import numpy as np
import pandas as pd
from pandas import DataFrame
from numpy import nan as NaN
#-----------------------------------------------
# 创建DataFrame
df1 = DataFrame(np.random.randint(0, 10, (4, 4)), index=[1,2,3,4], columns=list("abcd"))
#print(df1)
'''
a b c d
1 1 9 9 3
2 6 9 9 6
3 6 1 3 0
4 8 2 7 1
'''
#-----------------------------------------------
# 字典转换成DataFrame
#用法1
dict1={
'Province': ['Guangdong', 'Beijing', 'Qinghai', 'Fujian'],
'pop': [1.3, 2.5, 1.1, 0.7],
'year': [2018, 2018, 2018, 2018]}
df2