spark数据帧不在之后删除列测向下降()操作

2024-06-25 23:07:23 发布

您现在位置:Python中文网/ 问答频道 /正文

我用的是jupyter笔记本和spark2.4.3。你知道吗

game_reviews = spark.read.format("csv").option("header", "true").load("./amazon_reviews_us_Video_Games_v1_00.tsv")
#reading is fine

game_reviews_2_columns =game_reviews.drop(
'marketplace','review_id','product_parent','product_title','product_category',
                       'helpful_votes' ,'total_votes','vine','verified_purchase','review_headline',
                       'review_body','review_date')

运行此代码

game_reviews_2_columns.columns

仍然提供所有列:

['marketplace\tcustomer_id\treview_id\tproduct_id\tproduct_parent\tproduct_title\tproduct_category\tstar_rating\thelpful_votes\ttotal_votes\tvine\tverified_purchase\treview_headline\treview_body\treview_date']

我做错什么了?你知道吗


Tags: columnsidgametitleproductpurchasereviewparent
1条回答
网友
1楼 · 发布于 2024-06-25 23:07:23

它没有正确读取标题,它是一个列和标签的巨大字符串列表。你知道吗

game_reviews = spark.read.format("csv").option("header", "true").
    option("delimiter","\t"). #this is the parameter

load("./amazon_reviews_us_Video_Games_v1_00.tsv")

我可以指定schema并包含它,但它工作得很好。你知道吗

相关问题 更多 >