0

This is a copy and paste line from a data science experiment I am trying to run.

for col,num in zip(df.toPandas().describe().columns(),range(1,11)):

It shows output but not on Databricks.

Error is:

TypeError: 'Index' object is not callable

Any ideas?

1 Answer 1

2

As the error says, you can't call an index object, which is df.toPandas().describe().columns. Try removing the brackets:

for (col, num) in zip(df.toPandas().describe().columns, range(1,11)):

perhaps a better way is to use enumerate instead of zip, which avoids the need to hard code the number of columns:

for (num, col) in enumerate(df.toPandas().describe().columns):
Sign up to request clarification or add additional context in comments.

8 Comments

It was copied from something that shows output. Crappy
Maybe some versioning problems?
Although I don't remember any recent pandas versions which calls columns
enumerate did not work, the other did. You beaut.
ah, enumerate starts from 0, so you need to add 1 to num inside the for loop.
|

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.