[英]How to take only index 0 of a list of a pandas dataframe and create a new dataframe?
In resume:在简历中:
i have a Dataframe like this in python pandas:我在 python pandas 中有一个这样的数据框:
Code Name
13 [Robert, RoBert, robert, robert man]
2 [Barbie, BarBie, barbie, barbie womam]
5 [ShibA, Shiba, Shibba, shiba dog]
100 [HusKYE, huskye, Huskye, huskye dog]
I want to transform it into this:我想把它改成这样:
Code Name
13 Robert
2 Barbie
5 ShibA
100 HusKYE
How can i do it?我该怎么做?
You can use pandas.Series.apply .您可以使用pandas.Series.apply 。
df['First_Name'] = df['Name'].apply(lambda names: names[0])
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.