Q:

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

>>> df = pd.DataFrame({'A': a, 'B': b}, index=[0])
>>> df
   A  B
0  2  3
1
>>> df = pd.DataFrame({'A': [a], 'B': [b]})
>>> df
   A  B
0  2  3
0
This machine learning error message says pandas DataFrame needs an index. While pandas create data frame from a dictionary, it is expecting its value to be a list or dict. If you give it a scalar , you'll also need to supply index. What this is essentially asking for is a column number for each dictionary items. You can solve this issue by using the following methods:

x = 100
y = 200
df = pd.DataFrame({'X': [x], 'Y': [y]}) //adding values inside squire brackets

Or

df = pd.DataFrame({'X': x, 'Y': y}, index=[0]) //pass index value

http://net-informations.com/ds/iq/mliq.htm
0

New to Communities?

Join the community