DEV Community

Discussion on: Regression from scratch  -  Wine quality prediction

Collapse
 
alcaraz_pico profile image
Eric Alcaraz del Pico

I have a problem:
correlations = df.corr()['quality'].drop('quality')
Keyerror : 'quality'
Some idea?

Collapse
 
bishtgovind1988 profile image
Govind Bisht

Hey Eric,

Please pass the separator value while reading the CSV file.

ex:
df = pd.read_csv('winequality-red.csv', sep=";")

Collapse
 
apoorvadave profile image
Apoorva Dave

The dataframe into which you have read csv file should contain the column 'quality'.
correlations = df.corr()['quality'].drop('quality')
Here we are trying to find correlations between column quality and all the other columns other than quality. 'quality' is our target variable.

Collapse
 
alcaraz_pico profile image
Eric Alcaraz del Pico • Edited

This my csv

I have this column named 'quality'.
This is my code:

And i am having the problem:

Help pls :,(

Thread Thread
 
apoorvadave profile image
Apoorva Dave

I see you have value for 'quality' column in the dataset but it is not being read properly. As you can see in the output row 2 and 3 are showing .... but values are present in the actual dataset. Can you try printing df['quality'] and see are there are blank values for it?

Thread Thread
 
bishtgovind1988 profile image
Govind Bisht

It is reading all the columns as one column. You need to pass the separator while reading the CSV file.

ex:
df = pd.read_csv('winequality-red.csv', sep=";")