我很难连接这两个Dataframe视图,因为无法修改spark scala中的特定列值。我想我必须做一个转置/连接的方式,但无法解决它。
这是第一个Dataframe:
var sample_df = Seq(("john","morning","7am"),("john","night","10pm"),("bob","morning","8am"),("bob","night","11pm"),("phil","morning","9am"),("phil","night","10pm")).toDF("person","time_of_day","wake/sleep hour")
下面是第二个Dataframe:
var sample_df2 = Seq(("john","6am","11pm"),("bob","7am","2am"),("phil","8am","1am")).toDF("person","morning_earliest","night_latest")
下面是我希望生成的Dataframe:
var resulting_df = Seq(("john","morning","7am","6am"),("john","night","10pm","11pm"),("bob","morning","8am","7am"),("bob","night","11pm","2am"),("phil","morning","9am","8am"),("phil","night","10pm","1am")).toDF("person","time_of_day","wake/sleep hour","earliest/latest")
任何帮助都将不胜感激!谢谢,祝你今天愉快!
1条答案
按热度按时间0ejtzxu11#