TypeError: 'DataFrame' object is not calla

2020-03-31 01:49发布

问题:

i'm new to python and machine learning and try to learn the subject , i'm following an online course , i have imported a dataset in jupyter notebook and try to execute following python script on it

#creating a scatter plot matrix
%matplotlib inline

import seaborn as sns
num_cols = ["Age","Height","Weight","Duration","Heart_Rate","Body_Temp","Calories"]
sns.pairplot(frame(num_cols),size=2)

my dataset as follows

but when i run the code i get

TypeError Traceback (most recent call last) in () 4 import seaborn as sns 5 num_cols = ["Age","Height","Weight","Duration","Heart_Rate","Body_Temp","Calories"] ----> 6 sns.pairplot(frame(num_cols),size=2)

TypeError: 'DataFrame' object is not callable

As a begginer i can't find a solution for this if anyone can help on this very much appreciated.

thanks.

回答1:

You should create an intermediate DataFrame:

import pandas as pd

%matplotlib inline

import seaborn as sns
num_cols = ["Age","Height","Weight","Duration","Heart_Rate","Body_Temp","Calories"]
df = pd.DataFrame(columns=num_cols)
sns.pairplot(df,size=2)


回答2:

i have found the issue , and thought this will help for a beginner i have missed square brackets in

sns.pairplot(frame(num_cols),size=2)

it should be

sns.pairplot(frame[num_cols],size=2)