in python, i am using pandas to read a csv file when its working fine tho with other functions but facing an error while using a line


i imported panda as pd

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

   dataset.plot(x='tempmin', y='tempmax', style='o')
   pit.figure(figsize=(15,10)) #these are working fine
   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

i was expecting to use this to train my algo but i am stuck on a variable??

Asked By: pinocchi's dev



Only one dimension size can be unspecified in reshape function. I guess you want to convert the dataframe columns to column vectors to feed into some training module, then you need to reshape to (-1, 1) not (-1, -1), i.e.

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