Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
228 views
in Technique[技术] by (71.8m points)

python - pyspark 'Index' object is not callable

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?

question from:https://stackoverflow.com/questions/65600924/pyspark-index-object-is-not-callable

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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):

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...