Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Data Science by (17.6k points)

I want to iteratively assign col names to the value s for each column name that I have. I have tried everything but cannot get through this. The following code throws an error:

for i in continuous_data.columns :

   plt.figure()

   continuous_data.plot(x="Lattitude", y="Longtitude", kind="scatter",alpha=0.4,figsize=(12,10),c="Price",colormap="gist_rainbow",s=continuous_data.i,colorbar=True)

   plt.legend()

The error is:

    ---------------------------------------------------------------------------

AttributeError                            Traceback (most recent call last)

<ipython-input-8-2489dccddba7> in <module>()

      1 for i in continuous_data.columns :

      2     plt.figure()

----> 3     continuous_data.plot(x="Lattitude", y="Longtitude", kind="scatter", alpha=0.4,figsize=(12,10),c="Price",colormap="gist_rainbow",s=continuous_data.i,colorbar=True)

      4     plt.legend()

/opt/conda/lib/python3.6/site-packages/pandas/core/generic.py in __getattr__(self, name)

   3612             if name in self._info_axis:

   3613                 return self[name]

-> 3614             return object.__getattribute__(self, name)

   3615 

   3616     def __setattr__(self, name, value):

AttributeError: 'DataFrame' object has no attribute 'i'

<matplotlib.figure.Figure at 0x7ff9c144aa58>

When I am doing the following, it is yielding correct column names though:

    for i in continuous_data.columns:

    print(i)

Rooms

Price

Distance

Postcode

Bedroom2

Bathroom

Car

BuildingArea

Landsize

Lattitude

Longtitude

Propertycount

Can you guys help me with this? Link to the kernel on Kaggle is:https://www.kaggle.com/shinydhar/melbourne-housing-analysis

1 Answer

0 votes
by (41.4k points)

Here, the problem is in this piece of code:

s=continuous_data.i

So, replace it with this:

s=continuous_data[i]

If you wish to learn Pandas visit this Pandas Tutorial.

Browse Categories

...