我是 PySpark 的新手。
我有一个DataFrame
df
包含“device_type”列的 Spark 。
我想将“平板电脑”或“电话”中的每个值替换为“电话”,并将“PC”替换为“桌面”。
在 Python 中,我可以执行以下操作,
deviceDict = {'Tablet':'Mobile','Phone':'Mobile','PC':'Desktop'}
df['device_type'] = df['device_type'].replace(deviceDict,inplace=False)
Run Code Online (Sandbox Code Playgroud)
如何使用 PySpark 实现这一目标?谢谢!