- Hands-On Exploratory Data Analysis with Python
- Suresh Kumar Mukhiya Usman Ahmed
- 89字
- 2021-06-24 16:44:55
Data cleansing
Let's create a CSV file with only the required fields. Let's start with the following steps:
Import the csv package:
import csv
2.reate a CSV file with only the required attributes:
with open('mailbox.csv', 'w') as outputfile:
writer = csv.writer(outputfile)
writer.writerow(['subject','from','date','to','label','thread'])
for message in mbox:
writer.writerow([
message['subject'],
message['from'],
message['date'],
message['to'],
message['X-Gmail-Labels'],
message['X-GM-THRID']
]
)
The preceding output is a csv file named mailbox.csv. Next, instead of loading the mbox file, we can use the CSV file for loading, which will be smaller than the original dataset.
推薦閱讀
- 流量的秘密:Google Analytics網站分析與優化技巧(第2版)
- C語言程序設計(第3版)
- Redis入門指南(第3版)
- Cocos2d-x游戲開發:手把手教你Lua語言的編程方法
- 精通搜索分析
- 匯編語言程序設計(第2版)
- 編寫高質量代碼:改善C程序代碼的125個建議
- Linux命令行與shell腳本編程大全(第4版)
- C語言程序設計上機指導與習題解答(第2版)
- Python 3.7從入門到精通(視頻教學版)
- Swift語言實戰晉級
- Clojure Polymorphism
- HTML5+CSS3+jQuery Mobile+Bootstrap開發APP從入門到精通(視頻教學版)
- Lync Server Cookbook
- Learning jqPlot