如何复制原始dataframe的每一行,然后添加dataframe2,这样我的最终输出是:我正在pyspark dataframe中用python编写这个。
drnojrws1#
您需要的是交叉连接:
result = df1.crossJoin(df2) result.show() # +------+--------+------+-------+------------+-----------------+ # | name| address|salary|bonus %|allowances %|employee category| # +------+--------+------+-------+------------+-----------------+ # | Tom| Chicago| 75000| 5| 5| onsite| # | Tom| Chicago| 75000| 10| 10| off shore| # |Martha|New york| 80000| 5| 5| onsite| # |Martha|New york| 80000| 10| 10| off shore| # |Samuel| Phoenix| 90000| 5| 5| onsite| # |Samuel| Phoenix| 90000| 10| 10| off shore| # | Rom| Dallas| 65000| 5| 5| onsite| # | Rom| Dallas| 65000| 10| 10| off shore| # +------+--------+------+-------+------------+-----------------+
1条答案
按热度按时间drnojrws1#
您需要的是交叉连接: