Correlation Function is not working

df.corr() function is not working for all both databases ‘diamonds’ and ‘titanic’

Can anybody help me?

Hi @sobia ,

It seems there is value error in the certain column.
i assume you have a column which has values both ‘male’ or ‘female’.

Based on pandas docs you need to convert your column values into float or int or boolean.
https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.corr.html

If you have only ‘male’ or ‘female’ value you can turn into numeric value that represent the real value, for example 0 and 1.

def gender_to_number(gender):
    if gender == 'female':
        return 0
    return 1

df['gender'] = df['gender'].apply(gender-to_number)