Last answered:

04 May 2024

Posted on:

28 Dec 2023

0

sns.scatterplot error

Hi 365 Data Science

I do not understand why I have this error. Please advise


Thanks

1 answers ( 0 marked as helpful)
Super learner
This user is a Super Learner. To become a Super Learner, you need to reach Level 8.
Posted on:

04 May 2024

0

This is the signature of a scatterplot:

sns.scatterplot(
    data=None,
    *,
    x=None,
    y=None,
    hue=None,
    size=None,
    style=None,
    palette=None,
    hue_order=None,
    hue_norm=None,
    sizes=None,
    size_order=None,
    size_norm=None,
    markers=True,
    style_order=None,
    legend='auto',
    ax=None,
    **kwargs,
)

What this means is that when you use sns.scatterplot, it reads your first argument (if the name of the argument is not specified), as the data to be used, after the first argument, you need to specify the name of the argument you are passing. The correction needed to be made to your code is as follows:

sns.scatterplot(x=scatter["Area (ft.)"], y=scatter["Price"])

This made just two subtle differences to your code; passing the arguments as "x" and "y" respectively to specify what the arguments you passed stands for. Alternatively the following two version works just exactly the same way:

sns.scatterplot(data=scatter, x="Area (ft.)", y="Price")
sns.scatterplot(scatter, x="Area (ft.)", y="Price")

I guess the method has changed since this video was recorded.

I hope this helps both either the questioner or others or both.

Submit an answer