0

tried this:

df = pd.DataFrame(list(sample.items()),columns = ['id','age','chest_pain_type',
        'blood_sugar','rest_electro','max_heart_rate', 'exercice_angina','rest_blood_pressure']) 

Got this: 8 columns passed, passed data had 2 columns and the error is occuring in this line:

columns = _validate_or_indexify_columns(content, columns)

the dictionary 'sample':

    {'age': '34', 'max_heart_rate': '123', 'rest_blood_pressure': '132',
     'blood_sugar': '1', 'exercice_angina': '0', 'chest_pain_type': 'typ_angina',
 'rest_electro': 'normal', 'id': 8808}
  • Check [this](https://stackoverflow.com/a/46577585/2901002) - `df = pd.DataFrame([sample],columns = ['id','age','chest_pain_type', 'blood_sugar','rest_electro','max_heart_rate', 'exercice_angina','rest_blood_pressure']) ` – jezrael May 12 '21 at 12:00

1 Answers1

0

If you using all scalar values, you must pass an index

df = pd.DataFrame({'age': '34', 'max_heart_rate': '123', 'rest_blood_pressure': '132',
     'blood_sugar': '1', 'exercice_angina': '0', 'chest_pain_type': 'typ_angina',
 'rest_electro': 'normal', 'id': 8808},index = [0])


    age max_heart_rate  rest_blood_pressure blood_sugar exercice_angina chest_pain_type rest_electro    id
0   34    123                  132              1             0    typ_angina   normal  8808
Rishin Rahim
  • 655
  • 4
  • 14