votes up 4

If using all scalar values, you must pass an index

Package:
pandas
github stars 30911
Exception Class:
ValueError

Raise code

have_dicts = True
                indexes.append(list(val.keys()))
            elif is_list_like(val) and getattr(val, "ndim", 1) == 1:
                have_raw_arrays = True
                raw_lengths.append(len(val))

        if not indexes and not raw_lengths:
            raise ValueError("If using all scalar values, you must pass an index")

        if have_series:
            index = union_indexes(indexes)
        elif have_dicts:
            index = union_indexes(indexes, sort=False)

        if have_raw_arrays:
😲  Walkingbet is Android app that pays you real bitcoins for a walking. Withdrawable real money bonus is available now, hurry up! 🚶

Ways to fix

votes up 3 votes down

Error code:

import pandas as pd

df = pd.DataFrame({'A':3,'B':2})

print(df)

When defining scalar variables as a column, you have to make sure that values are in the list like or you defined index argument.

Fix code (1):

import pandas as pd

df = pd.DataFrame({'A':3,'B':2},index=[1])

print(df)

Fix code(2):

import pandas as pd

df = pd.DataFrame({'A':[3],'B':[2]})
print(df)
Jul 20, 2021 anonim answer
anonim 13.0k

Add a possible fix

Please authorize to post fix