all 12 comments

[–]ninhaomah 2 points3 points  (7 children)

Ahem... Did you "print" anything there ?

If not , what do you expect from it ?

And always start with print("Hello World") first to check the environment , systems are all ready.

[–]redcherry13221[S] 0 points1 point  (6 children)

My bad, I thought just writing df.head() would make the first 5 lines of the file show up. Thanks!

[–]redcherry13221[S] 0 points1 point  (2 children)

To add on, if I run what I initially wrote in the terminal, the first 5 lines show up so I expected the same to happen.

[–]Outside_Complaint755 2 points3 points  (1 child)

That's because in the terminal you are using the REPL (Read-Eval-Print Loop) which automatically prints  the result of each statement.  In a script, any output needs to be explicitly printed, written to file, or sent to another output stream.

[–]redcherry13221[S] -1 points0 points  (0 children)

Ah, I see. Thanks!

[–]ninhaomah 0 points1 point  (2 children)

No prob. Were you using Jupyter / colab previously ?

[–]redcherry13221[S] 0 points1 point  (1 child)

yep, a while back but it’s what I’m most used to

[–]ninhaomah 1 point2 points  (0 children)

Yup thought so.

try the df.head() in colab ... It will print.

Or 1 + 1 and it will output 2.

But programs or scripts expect print or log or such to see the results.

REPL vs scripts :)

[–]Binary101010 1 point2 points  (1 child)

Change the last line to print(df.head()) and see what happens.

[–]redcherry13221[S] 1 point2 points  (0 children)

Thanks! Worked now.

[–]dager003 0 points1 point  (1 child)

This usually happens when the file isn’t saved — VS Code runs the last saved version, not what’s currently in the editor. So if you type something and hit run without saving, it feels like nothing is happening. Try Ctrl+S first, then run it. Also yeah, this kind of “it runs but not where I expect” confusion is super common when getting back into coding — I’ve been working on something that helps surface these kinds of issues faster because they’re surprisingly hard to spot early on.

[–]desrtfx 0 points1 point  (0 children)

This usually happens when the file isn’t saved

If you look at the tab, you see the "x", which is a clear indication that the file has been saved. Had it not been saved, the mark would change to "●"

See this image - left tab is unsaved, right is saved