趁着今天电脑进水 进去检修,写点平时用的东西。在进行数据分析的时候会遇到字段类型是相反的,之前我显示出来的报表呈现字段是这样的 :
table name : t1
column name :robot , not_robot
最后效果是:
robot not_robot
30 40
这样子有缺点就是视图总觉得少点什么,于是最近使用spark dataframe实现了这样的功能:
table name : t1
column name :robot , not_robot
最后效果是:
act_type act_num
robot 30
not_robot 40
这样子就实现了两个不同的子段在一列 ,在别人看视图的时候可以去选择看robot的连续时间段内的变化情况。非常的方便。
实现过程:使用withcolumn和withcolumnNewname方法 就是这两个方法,可能字母有误,,没在电脑旁边。
就这样吧。