junayeD
junayeD

Reputation: 27

Why SyntaxError: multiple statements found while compiling a single statement in Python IDE?

import pandas as pd

wine_dict = {
    'red_wine': [3, 6, 5],
    'white_wine':[5, 0, 10]
}
sales = pd.DataFrame(wine_dict, index=["adam", "bob", "charles"])
print(sales)

Please help me to run the code in my IDE.

Upvotes: 1

Views: 3075

Answers (2)

Mihir Joshi
Mihir Joshi

Reputation: 450

The code you have pasted contains indented statements. Indents have a meaning in Python.

Leading whitespace (spaces and tabs) at the beginning of a logical line is used to compute the indentation level of the line, which in turn is used to determine the grouping of statements.

Code output

Your code works fine after removing all the indents.

Edit:

Your code after removing indents:

import pandas as pd

wine_dict = {
    'red_wine': [3, 6, 5],
    'white_wine':[5, 0, 10]
    }
sales = pd.DataFrame(wine_dict, index=["adam", "bob", "Charles"])
print(sales)

Upvotes: 2

Yogesh Kumar Wadhwa
Yogesh Kumar Wadhwa

Reputation: 49

you are running code in idle itself. go to new file paste the code and then run it.

I hope it works.

Upvotes: 1

Related Questions