查找空值并从 Pandas 中的数据框中删除
Find a null value and drop from a dataframe in Pandas
你好,我有一个像这样的数据框,有 500 多行。
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...
我想做的是在 "data" 列中找到 null 并从数据框中删除该行。我为它编写了代码,但我认为它没有按预期工作,因为行数没有改变。有人可以帮我解决这个问题吗?
我的代码:
for item in bigdata_comp_dropped.iterrows():
if item[1][4] == "":
bigdata_comp_dropped.drop(item[1])
尝试
bigdata_filtered = bigdata_comp_dropped[~bigdata_comp_dropped['data'].isnull()]
您只能使用布尔掩码保留 notnull 值:
df = df[df["data"].notnull()]
你好,我有一个像这样的数据框,有 500 多行。
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...
我想做的是在 "data" 列中找到 null 并从数据框中删除该行。我为它编写了代码,但我认为它没有按预期工作,因为行数没有改变。有人可以帮我解决这个问题吗?
我的代码:
for item in bigdata_comp_dropped.iterrows():
if item[1][4] == "":
bigdata_comp_dropped.drop(item[1])
尝试
bigdata_filtered = bigdata_comp_dropped[~bigdata_comp_dropped['data'].isnull()]
您只能使用布尔掩码保留 notnull 值:
df = df[df["data"].notnull()]