利用列表创建DataFrame数据类型
方法1 列表生成器
a =[x for x in range(1,10)], [y for y in range(1,10)], [z for z in range(1,10)]
data_Frame = DataFrame(a)
方法2 嵌套列表
'''生成DataFrame数据'''
# 导入库
import numpy as np
import pandas as pd
from pandas.core.frame import DataFrame
import os
import random
from pylab import *
mpl.rcParams['font.sans-serif'] = ['SimHei']
# os.getcwd() # 获取文件路径
# os.chdir(r'F:\数据') # 文件所在路径
# data = pd.read_excel('data.xls', 'Sheet0')
# data.head(10)
# '''数据分析查看'''
# data.describe()
data_list=[]
range_low = 1
range_high = 20
import random
for i in range(100): # 行
data_result = []
for j in range(20): #列
data1 = random.uniform(range_low, range_high) #%10
data_result.append(data1)
data_list.append(data_result)
data_Frame = DataFrame(data_list)
'''数据分析查看'''
data_Frame.describe()
'''保存'''
data_Frame.to_excel('mydata.xlsx', sheet_name='Sheet0',index=False)