当前位置:   article > 正文

python多列数据合并成一列_在pandas / python的同一数据框中将两列合并为一列

python列合并成一列

1586010002-jmsa.png

I have a question to merge two columns into one in the same dataframe(start_end), also remove null value. I intend to merge 'Start station' and 'End station' into 'station', and keep 'duration' according to the new column 'station'. I have tried pd.merge, pd.concat, pd.append, but I cannot work it out.

dataFrame of Start_end:

Duration End station Start station

14 1407 NaN 14th & V St NW

19 509 NaN 21st & I St NW

20 638 15th & P St NW. NaN

27 1532 NaN Massachusetts Ave & Dupont Circle NW

28 759 NaN Adams Mill & Columbia Rd NW

Expected output:

Duration stations

14 1407 14th & V St NW

19 509 21st & I St NW

20 638 15th & P St NW

27 1532 Massachusetts Ave & Dupont Circle NW

28 759 Adams M

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/知新_RL/article/detail/931346
推荐阅读
相关标签
  

闽ICP备14008679号