How to construct pandas using dataframe from values which gives us value error

255    Asked by AashnaSaito in Python , Asked on Feb 18, 2021
Answered by Aashna Saito

Here the error message says that for passing scalar values, you need to pass an index.


So you can either not utilize scalar values for the columns: >>> df = pd.DataFrame({'A': [a], 'B': [b]})

>>> df

A B

0 2 3

or use you can use scalar values and pass an index:

>>> df = pd.DataFrame({'A': a, 'B': b}, index=[0])

>>> df

A B

0 2 3



Your Answer

Interviews

Parent Categories