注册
登录
大数据安全
根据多个关键字对Pandas数据框上的行进行排序
返回
根据多个关键字对Pandas数据框上的行进行排序
作者:
只怕再见是故人
发布时间:
2024-04-04 12:39:00 (2月前)
您好,我正在学习数据科学,并且正在制作具有某些属性的大数据公司列表。 目前,我的数据框data看起来像这样。 ``` company_url company tag_line product data 0 https://angel.co/billguard BillGuard The fastest smartest way to track your spendin... BillGuard is a personal finance security app t... New York City · Financial Services · Security ... 1 https://angel.co/tradesparq Tradesparq The world's largest social network for global ... Tradesparq is Alibaba.com meets LinkedIn. Trad... Shanghai · B2B · Marketplaces · Big Data · Soc... 2 https://angel.co/sidewalk Sidewalk Hoovers (D&B) for the social era Sidewalk helps companies close more sales to s... New York City · Lead Generation · Big Data · S... 3 https://angel.co/pangia Pangia The Internet of Things Platform: Big data mana... We collect and manage data from sensors embedd... San Francisco · SaaS · Clean Technology · Big ... 4 https://angel.co/thinknum Thinknum Financial Data Analysis Thinknum is a powerful web platform to value c... New York City · Enterprise Software · Financia... ``` 我想使用某些关键字(例如“大数据”)对“数据”列进行排序,并使用行创建一个新的数据框。 我当时想先找到合适的行,然后将它们放入列表中,然后根据行列表对数据框和数据进行排序,但是第一部分出现了错误。 我的代码: ``` comp_rows = [] a = ['Data','Analytics','Machine Learning','Deep','Mining'] for count, item in enumerate(data.data): if any(x in item for x in a): comp_rows.append(count) ``` 错误: ``` --------------------------------------------------------------------------- TypeError Traceback (most recent call last)
in
() 3 4 for count, item in enumerate(data.data): ----> 5 if any(x in item for x in a): 6 comp_rows.append(count)
in
((x,)) 3 4 for count, item in enumerate(data.data): ----> 5 if any(x in item for x in a): 6 comp_rows.append(count) TypeError: argument of type 'float' is not iterable ``` 有人可以帮我吗?
收藏
举报
2 条回复
1#
回复此人
春风助手
|
2020-08-07 14-52
如果您data.data是一个字符串列表,它将起作用,但是在那里找到了一个浮点数。尝试替换 if any(x in item for x in a): 为 if any(x in str(item) for x in a):
编辑
登录
后才能参与评论