pandas資料匯入:
1 import pymysql 2 import pandas as pd 3 4 #匯入csv檔案 5 data = pd.read_csv(`file_name`) 6 7 #匯入excel檔案 8 data = pd.read_excel(`file_name`) 9 10 #從mysql匯入資料 11 conn = pymysql.connect( 12 host = `127.0.0.1`, 13 user = `user_name`, 14 password = `password` 15 db = `db_name`) 16 sql = `SELECT * FROM tb_name` 17 data = pd.read_sql(sql, conn) 18 19 #轉為DataFrame型別 20 df = pd.DataFrame(data)