Data Analysis with Python - Data Analysis Example A

Tell us what’s happening:

I’m working with Google Colab on Lecture_1 file of Data Analysis Example A. When I want to print correlation of numerical values as per code below:

fig = plt.figure(figsize=(8,8))
plt.matshow(corr, cmap=‘RdBu’, fignum=fig.number)
plt.xticks(range(len(corr.columns)), corr.columns, rotation=‘vertical’);
plt.yticks(range(len(corr.columns)), corr.columns);

it returns ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

Please help to fix the code

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.0.0 Safari/537.36

Challenge Information:

Data Analysis with Python - Data Analysis Example A

Welcome to the forum :wave:

Please share your complete code, thanks.

Thank you for responding. I am now switching from Google Colab to Jupyter Notebook and it works fine. But now I have to deal with %matplotlib inline not working :joy:

There can be a lot of differences between different tools and different versions of installed packages, just keep that in mind. These videos are also 4 years old so many of the packages used have been significantly updated and changed.

A lot of the problems will be related to this, so I would not try to troubleshoot this too deeply, you will get into situations where certain specific methods will lead to a dead end.

I suggest learning what you can of the fundamentals and moving on quickly. Do not spend time troubleshooting 4 year old videos.

1 Like