开始使用免费开始使用

从 parquet 文件抽取数据

从源系统摄取数据的常见方式之一是读取文件,例如 CSV 文件。随着数据规模变大,对更优文件格式的需求催生了新的面向列的文件类型,如 parquet 文件。

在本练习中,您将练习从 parquet 文件中抽取数据。

本练习是课程的一部分

使用 Python 的 ETL 和 ELT

查看课程

练习说明

  • 将路径为 "sales_data.parquet" 的 parquet 文件读入一个 pandas DataFrame。
  • 使用 print() 检查该 DataFrame 的数据类型。
  • 输出该 DataFrame 的形状以及其前几行。

交互式实操练习

通过完成这段示例代码来试试这个练习。

import pandas as pd

# Read the sales data into a DataFrame
sales_data = pd.____("____", engine="fastparquet")

# Check the data type of the columns of the DataFrames
print(sales_data.____)

# Print the shape of the DataFrame, as well as the head
print(sales_data.____)
print(sales_data.____())
编辑并运行代码