2015-05-06 47 views
0

嗨,我正在学习数据科学,并且正在制作一个具有某些属性的大数据公司列表。基于多个关键字对Pandas数据框上的行进行排序

当前我的数据帧数据看起来像这样。

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) 
<ipython-input-174-afeee7d3d179> in <module>() 
     3 
     4 for count, item in enumerate(data.data): 
----> 5  if any(x in item for x in a): 
     6   comp_rows.append(count) 

<ipython-input-174-afeee7d3d179> in <genexpr>((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 

有人能帮助我吗?

回答

0

如果你的data.data是一个字符串列表,但是在那里找到了一个浮点数,它会起作用。尝试替换
if any(x in item for x in a):if any(x in str(item) for x in a):

+0

谢谢,它解决了! – pythonlearner

相关问题