1
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.

ooo
  • 512
  • 1
  • 7
  • 27
junayeD
  • 27
  • 7
  • 3
    Unindent your code. `import` should be at the very beginning of the line, not indented four spaces. – John Gordon Jul 20 '20 at 05:01
  • 1
    Indentation issues should not produce "multiple statements" error. There are a plenty of questions on SO with the same error: https://stackoverflow.com/questions/21226808/syntaxerror-multiple-statements-found-while-compiling-a-single-statement, and I believe this code is executed via shell, which tries to execute the whole block as a single statement. This [question](https://stackoverflow.com/questions/46262109/syntax-error-multiple-statements-found-while) includes a good image of what is possibly happening here – awesoon Jul 20 '20 at 05:11
  • 1
    How are you running this code? Are you really using an IDE. If so which one? Or do you mean Python IDLE? – Code-Apprentice Jul 20 '20 at 05:14
  • 1
    Does this answer your question? [SyntaxError: multiple statements found while compiling a single statement](https://stackoverflow.com/questions/21226808/syntaxerror-multiple-statements-found-while-compiling-a-single-statement) – Code-Apprentice Jul 20 '20 at 05:16

2 Answers2

2

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)
Mihir Joshi
  • 426
  • 5
  • 14
  • 1
    Can you please paste my code again removing all the indents.. – junayeD Jul 20 '20 at 05:16
  • 2
    I don't think you can assume this, that could be just the way it got pasted into SO. Lots of people add extra indentation when posting. – Barmar Jul 20 '20 at 05:18
  • 1
    @junayeD added the correct code, please take a look at it. – Mihir Joshi Jul 20 '20 at 05:34
  • @MihirJoshi bro I run the code in my Python IDE but don't know why the error message is still seeing. I take a screenshot of my IDE after running the code with indents. I can't add image in the comment section. Check it here: https://drive.google.com/file/d/10_XIcCk9UWTXdhjoT0QYaurIM1-62Qq5/view?usp=sharing – junayeD Jul 26 '20 at 06:17
  • @junayeD the file is private, I requested access. If you can't add an image in the comment section, you can share the imgur link as well (it's public, unlike GDrive). – Mihir Joshi Jul 26 '20 at 06:38
1

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

I hope it works.

  • I run the code in my Python IDE but don't know why the error message is still seeing. I take a screenshot of my IDE after running the code with indents. I can't add image in the comment section. Check it here: https://drive.google.com/file/d/10_XIcCk9UWTXdhjoT0QYaurIM1-62Qq5/view?usp=sharing – junayeD Jul 26 '20 at 06:19
  • @junayeD Need to see the screenshot – Yogesh Kumar Wadhwa Jul 27 '20 at 05:40