- PySpark Cookbook
- Denny Lee Tomasz Drabas
- 75字
- 2021-06-18 19:06:37
.filter(...) transformation
The filter(f) transformation returns a new RDD based on selecting elements for which the f function returns true. Therefore, look at the following code snippet:
# User filter() to filter where second column == "WA"
(
airports
.map(lambda c: (c[0], c[1]))
.filter(lambda c: c[1] == "WA")
.take(5)
)
This will produce the following output:
# Output
[(u'Bellingham', u'WA'),
(u'Moses Lake', u'WA'),
(u'Pasco', u'WA'),
(u'Pullman', u'WA'),
(u'Seattle', u'WA')]
推薦閱讀
- Boost程序庫完全開發指南:深入C++”準”標準庫(第5版)
- OpenDaylight Cookbook
- vSphere High Performance Cookbook
- SEO智慧
- Banana Pi Cookbook
- 名師講壇:Java微服務架構實戰(SpringBoot+SpringCloud+Docker+RabbitMQ)
- Microsoft Dynamics GP 2013 Reporting, Second Edition
- 零基礎學Python網絡爬蟲案例實戰全流程詳解(高級進階篇)
- Express Web Application Development
- Node.js區塊鏈開發
- WildFly Cookbook
- Java程序設計教程
- Python預測之美:數據分析與算法實戰(雙色)
- Applied Deep Learning with Python
- Monitoring Docker