Skip to Content
基于AWS的数据科学实践
book

基于AWS的数据科学实践

by Chris Fregly, Antje Barth
September 2022
Intermediate to advanced
549 pages
11h 27m
Chinese
China Electric Power Press Ltd.
Content preview from 基于AWS的数据科学实践
探索数据集
|
161
5.3
查询数据仓库
在此处,我们会使用
Amazon Redshift
来查询并可视化用例。与
Athena
的例子相似,
我们首先需要准备
SageMaker Studio
环境。
5.3.1
从
SageMaker Studio
运行一条
Amazon Redshift
示例查询
在以下示例中,我们会查询数据集来获取与每个产品类别关联的唯一客户的数量。
我们可以使用
pandas
的
read_sql_query
函数来运行
SQLAlchemy
查询并存储查询
结果到
pandas
的数据帧:
df = pd.read_sql_query("""
SELECT product_category, COUNT(DISTINCT customer_id) as num_customers
FROM redshift.amazon_reviews_tsv_2015
GROUP BY product_category
ORDER BY num_customers DESC
""", engine)
df.head(10)
输出应如下所示:
product_category num_customers
Wireless 1979435
Digital_Ebook_Purchase 1857681
Books 1507711
Apparel 1424202
Home 1352314
PC 1283463
Health & Personal Care 1238075
Beauty 1110828 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

设计机器学习系统

设计机器学习系统

Chip Huyen
Python设计模式(第2版)

Python设计模式(第2版)

Posts & Telecom Press, Chetan Giridhar
AWS认证数据工程师助理考试指南

AWS认证数据工程师助理考试指南

Sakti Mishra, Dylan Qu, Anusha Challa

Publisher Resources

ISBN: 9787519869663