資源簡介
航空公司客戶價值大數據分析全部的源代碼,使用python編寫,含數據部分
代碼片段和文件信息
#-*-?coding:?utf-8?-*-?
#對數據進行基本的探索
#返回缺失值個數以及最大最小值
import?pandas?as?pd
datafile=?‘../data/air_data.csv‘?#航空原始數據第一行為屬性標簽
resultfile?=?‘../tmp/explore.xls‘?#數據探索結果表
data?=?pd.read_csv(datafile?encoding?=?‘utf-8‘)?#讀取原始數據,指定UTF-8編碼(需要用文本編輯器將數據裝換為UTF-8編碼)
explore?=?data.describe(percentiles?=?[]?include?=?‘all‘).T?#包括對數據的基本描述,percentiles參數是指定計算多少的分位數表(如1/4分位數、中位數等);T是轉置,轉置后更方便查閱
explore[‘null‘]?=?len(data)-explore[‘count‘]?#describe()函數自動計算非空值數,需要手動計算空值數
explore?=?explore[[‘null‘?‘max‘?‘min‘]]
explore.columns?=?[u‘空值數‘?u‘最大值‘?u‘最小值‘]?#表頭重命名
‘‘‘這里只選取部分探索結果。
describe()函數自動計算的字段有count(非空值數)、unique(唯一值數)、top(頻數最高者)、freq(最高頻數)、mean(平均值)、std(方差)、min(最小值)、50%(中位數)、max(最大值)‘‘‘
explore.to_excel(resultfile)?#導出結果
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????1221??2018-07-29?17:49??chapter7\demo\code\7-1_data_explore.py
?????文件????????849??2018-07-29?17:49??chapter7\demo\code\7-2_data_clean.py
?????文件????????555??2018-07-29?17:49??chapter7\demo\code\7-3_zscore_data.py
?????文件????????606??2018-07-29?17:49??chapter7\demo\code\7-4_KMeans_cluster.py
?????文件???14478308??2018-07-29?18:18??chapter7\demo\data\air_data.csv
?????文件????4203008??2018-07-29?18:18??chapter7\demo\data\zscoredata.xls
?????文件????6883328??2018-07-29?18:18??chapter7\demo\data\zscoreddata.xls
?????文件??????29696??2018-07-29?17:49??chapter7\demo\data\客戶信息屬性說明.xls
?????文件???????9728??2018-07-29?17:49??chapter7\demo\tmp\explore.xls
?????文件????6883328??2018-07-29?18:18??chapter7\demo\tmp\zscoreddata.xls
?????文件????????877??2018-07-29?17:49??chapter7\test\code\cluster_plot.py
?????文件????????849??2018-07-29?17:49??chapter7\test\code\data_clean.py
?????文件???????1221??2018-07-29?17:49??chapter7\test\code\data_explore.py
?????文件????????606??2018-07-29?17:49??chapter7\test\code\KMeans_cluster.py
?????文件????????555??2018-07-29?17:49??chapter7\test\code\zscore_data.py
?????文件???16496640??2018-07-29?18:17??chapter7\test\data\preprocesseddata.xls
?????文件????8340992??2018-07-29?18:17??chapter7\test\data\princompdata.xls
?????文件????4203008??2018-07-29?18:18??chapter7\test\data\zscoredata.xls
?????文件???14175130??2018-07-29?18:17??chapter7\拓展思考\拓展思考樣本數據.csv
?????目錄??????????0??2018-07-29?17:49??chapter7\demo\code
?????目錄??????????0??2018-07-29?18:18??chapter7\demo\data
?????目錄??????????0??2018-07-29?18:18??chapter7\demo\tmp
?????目錄??????????0??2018-07-29?17:49??chapter7\test\code
?????目錄??????????0??2018-07-29?18:18??chapter7\test\data
?????目錄??????????0??2018-07-29?18:17??chapter7\test\tmp
?????目錄??????????0??2018-07-29?17:49??chapter7\demo
?????目錄??????????0??2018-07-29?18:17??chapter7\test
?????目錄??????????0??2018-07-29?18:17??chapter7\拓展思考
?????目錄??????????0??2018-07-29?18:17??chapter7
-----------?---------??----------?-----??----
............此處省略2個文件信息
- 上一篇:tesserocr庫
- 下一篇:Python數據科學手冊源代碼
評論
共有 條評論