首页 > 解决方案 > TypeError:执行某些数据预处理时遇到“元组”对象不可调用

问题描述

检查变量 x 的形状时遇到错误

#imports
import numpy as np 
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
from sklearn.datasets import load_diabetes

#loading the dataset
dbt=load_diabetes()
#exploring the dataset
dbt.keys()
#Creating a dataframe that contains all the data
df_feat=pd.DataFrame(dbt['data'],columns=dbt['feature_names'])
#data preprocessing
x=df_feat
y=dbt['target']
x.shape()
y.shape()

标签: pythonpandasnumpy

解决方案


shape只是一个属性,而不是一个方法。使用x.shape而不是x.shape().


推荐阅读