在python中,我正在使用Pandas来读取一个csv文件,当它与其他函数一起工作时很好,但在使用一行时面临错误

e0bqpujr  于 2023-02-27  发布在  Python
关注(0)|答案(1)|浏览(76)

我把Pandas当作PD

dataset = pd.read_csv('C:\\Users\\Adminis....')

   dataset.plot(x='tempmin', y='tempmax', style='o')
   pit.show()
   
   pit.figure(figsize=(15,10)) #these are working fine
   pit.tight_layout()
   seaborninstance.distplot(dataset['tempmax'])
   pit.show()
   but i am getting in trouble while using this
   x = dataset['tempmin'].values.reshape(-1,-1)
   y = dataset['tempmax'].values.reshape(-1,-1)

   x = dataset['tempmin'].values.reshape(-1,-1)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   ValueError: can only specify one unknown dimension

我本来想用这个来训练我的算法,但是我被一个变量卡住了?

yuvru6vn

yuvru6vn1#

reshape函数中只能指定一个维度大小。我猜您想将 Dataframe 列转换为列向量以馈送到某个训练模块中,那么您需要将其整形为(-1,1)而不是(-1,-1),即

x = dataset['tempmin'].values.reshape(-1, 1)
   y = dataset['tempmax'].values.reshape(-1, 1)

相关问题