我有一个数据集,上面有一个公司的产品日生产率。我想在数据帧中添加一列,它将根据公司的日期顺序编号。在
例如
Acme产品1 1/1/2000 5
Acme产品1 1/2/2000 7
Acme Product2 2000年3月1日9
Acme Product2 3/2/2000 4
公司2 ProductX 2015年4月1日6
公司2 ProductX 2015年4月2日3
我想添加一个新列,例如:
Acme Product1 1/1/2000 51
Acme Product1 1/2/2000 72
Acme Product2 2000年3月1日91
Acme Product2 2000年3月2日42
公司2 ProductX 2015年4月1日61
公司2 ProductX 2015年4月2日32
公司2 ProductX 2015年4月2日23
所有这些都是为了让我能够在新专栏的基础上比较公司和他们的产品。所以他们一整天都在生产一种产品,而不考虑日期。在
您可以使用pyspark.pysql语言函数
row_number
(别名rowNumber
适用于spark <= 1.6.X
)。在首先,让我们创建数据帧:
现在要使用窗口:
^{pr2}$相关问题 更多 >
编程相关推荐