pyspark's flatMap in pandas

前端 未结 3 1261
南旧
南旧 2021-02-04 12:06

Is there an operation in pandas that does the same as flatMap in pyspark?

flatMap example:

>>> rdd = sc.parallelize([2, 3, 4])
>>> sort         


        
3条回答
  •  说谎
    说谎 (楼主)
    2021-02-04 12:44

    there are three steps to solve this question.

    import pandas as pd
    df = pd.DataFrame({'x': [[1, 2], [3, 4, 5]]})
    df_new = df['x'].apply(pd.Series).unstack().reset_index().dropna()
    df_new[['level_1',0]]`
    

提交回复
热议问题