- 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.
推薦閱讀
- Delphi程序設計基礎:教程、實驗、習題
- 精通搜索分析
- SQL基礎教程(視頻教學版)
- 精通Python設計模式(第2版)
- 快速念咒:MySQL入門指南與進階實戰(zhàn)
- NetBeans IDE 8 Cookbook
- 區(qū)塊鏈國產化實踐指南:基于Fabric 2.0
- ABAQUS6.14中文版有限元分析與實例詳解
- Web前端開發(fā)技術:HTML、CSS、JavaScript
- Java Hibernate Cookbook
- Google Adsense優(yōu)化實戰(zhàn)
- 例說FPGA:可直接用于工程項目的第一手經驗
- Flutter從0基礎到App上線
- Azure for Architects
- Java EE框架開發(fā)技術與案例教程