Ad
TypeError: Dropna() Got Multiple Values For Argument 'axis'
I am trying to drop a list of columns that are in df
cols = df.columns[df.isna().any()].tolist()
df = df.dropna([cols], axis = 1)
But I get the error
TypeError: dropna() got multiple values for argument 'axis'
Any ideas how I can drop the list in cols ?
Ad
Answer
I think need boolean indexing
with loc
:
df1 = df.loc[:, df.notna().all()]
#alternative with iverting mask by ~
#df1 = df.loc[:, ~df.isna().any()]
#alternative 1
#df1 = df.dropna(axis=1)
For your solution need drop
with omit list []
for remove columns:
cols = df.columns[df.isna().any()]
df1 = df.drop(cols, axis = 1)
print (df1)
Ad
source: stackoverflow.com
Related Questions
- → What are the pluses/minuses of different ways to configure GPIOs on the Beaglebone Black?
- → Django, code inside <script> tag doesn't work in a template
- → React - Django webpack config with dynamic 'output'
- → GAE Python app - Does URL matter for SEO?
- → Put a Rendered Django Template in Json along with some other items
- → session disappears when request is sent from fetch
- → Python Shopify API output formatted datetime string in django template
- → Can't turn off Javascript using Selenium
- → WebDriver click() vs JavaScript click()
- → Shopify app: adding a new shipping address via webhook
- → Shopify + Python library: how to create new shipping address
- → shopify python api: how do add new assets to published theme?
- → Access 'HTTP_X_SHOPIFY_SHOP_API_CALL_LIMIT' with Python Shopify Module
Ad