展开 production_country
回到这家流媒体初创公司的电影数据集。这次关注 production_country:每一行包含两个嵌套字段,一个是国家代码,另一个是国家名称。请将该 struct 展开,使这些字段成为常规的顶层列。
本练习是课程的一部分
使用 Polars 扩展与优化数据流水线
练习说明
- 将
production_country这个 struct 列展开,使其字段成为常规列。
交互式实操练习
通过完成这段示例代码来试试这个练习。
# Flatten the struct into columns
result = movies.____("production_country").select(
"movie_title", "code", "name"
).head(8)
print(result)