2

I was previously using the 'select' attribute for data frames, however that has been deprecated. Cannot find any specifics to the error I am receiving, any guidance/help would be much appreciated.

  df=df.loc(lambda x: not re.search('\d+_version_value', x), axis=1)

Exception has occurred: TypeError call() got multiple values for argument 'axis'

3 Answers 3

1

Looks like you need apply and not loc

df = df.apply(lambda x: not re.search('\d+_version_value', x), axis=1)
Sign up to request clarification or add additional context in comments.

Comments

0

From the pandas documentation on deprecated select:

Deprecated since version 0.21.0: Use df.loc[df.index.map(crit)] to select via labels

So, try something like this:

df.loc[df.index.map(lambda x: not re.search('\d+_version_value', x))]

Or if you are trying to select columns:

df.loc[:, df.columns.map(lambda x: not re.search('\d+_version_value', x))]

Example:

print(df.head())

   sepalLength  sepalWidth  petalLength  petalWidth species
0          5.1         3.5          1.4         0.2  setosa
1          4.9         3.0          1.4         0.2  setosa
2          4.7         3.2          1.3         0.2  setosa
3          4.6         3.1          1.5         0.2  setosa
4          5.0         3.6          1.4         0.2  setosa
df.loc[:, df.columns.map(lambda x: not re.search('Length', x))]

   sepalWidth  petalWidth species
0         3.5         0.2  setosa
1         3.0         0.2  setosa
2         3.2         0.2  setosa
3         3.1         0.2  setosa
4         3.6         0.2  setosa

Comments

0

Could you try this -- square brackets for indexing:

  df=df.loc[lambda x: not re.search('\d+_version_value', x.column)]

2 Comments

I get the invalid syntax error. :/ SyntaxError: invalid syntax
Do you have a column to do the re.search?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.