如何使用spark

时间:2019-06-19 19:34:38

标签: apache-spark pyspark apache-spark-sql

我是spark的新手,请假定我具有如下数据框

sensor       description
541163       PLC27.8Y.8Y35.Duration_R2_EquipmentDownCondition 
541163   PLC27.8Y.8Y35.Duration_R2_EquipmentDownCondition 
541163   PLC27.8Y.8Y35.Duration_R2_EquipmentDownCondition 
541163   PLC27.MIS_PLC27.8Y.8Y35.Duration_R2_EquipmentDownCondition 
541163   PLC27.MIS_PLC27.8Y.8Y35.Duration_R2_EquipmentDownCondition 
327036   PLC12.MIS_PLC12.6X.6x60.Duration_ST_CyclingCondition      
327041   PLC12.MIS_PLC12.6X.6x60.Duration_ST_TotalCycleCondition   
327036   PLC12.MIS_PLC12.6X.6x60.Duration_ST_CyclingCondition      
541142   PLC12.MIS_PLC12.6X.6x60.Duration_ST_DownCondition         
327036   PLC12.MIS_PLC12.6X.6x60.Duration_ST_CyclingCondition      

我想从description列中创建新列:

  • 如果description包含"DownCondition",请返回0
  • 如果存在CyclingCondition,请返回1
  • 如果存在EquipmentDownCondition,请返回2

0 个答案:

没有答案