简体   繁体   中英

group a column by names and get the corresponding values in pandas

name games
a    football
a    volleyball
b    cricket
c    tennis
c    football


 a    football, volleyball
 b    cricket
 c    tennis, football

i want to groupby names and get the corresponding values. i want something like this.. So when i call c, i should get corresponding two values like tennis, football

use GROUP_CONCAT if your dbms is mysql

select name,GROUP_CONCAT(games) 
from table group by name

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM