1、数据集来源
2、数据集字段信息
3、数据获取与转换
(1)默认数据保存在Mysql里面,所有数据取出后保存在all_data里面
import pymysql
connection = pymysql.connect("172.17.6.26","raa_user","bigdata123","risk_assessment_analysis",charset="utf8mb4",cursorclass=pymysql.cursors.DictCursor)
try:
with connection.cursor() as cursor:
sql = "select * from all_data";
cursor.execute(sql)
all_data = cursor.fetchall();
finally:
connection.close()
(2)把数据转换为DataFrame格式
data = pd.DataFrame(all_data)