In Introduction to Data Science step 5, the course directions ask me to paste in some code to a Python code to generate updated results. In this case the assumption is that 15 results will be returned, with ‘urban’ and ‘rural’ columns included in the returned set. I could not get this to happen, as shown in my screen shot. What am I doing wrong? Does the ‘print’ line not always need to occur last in the code lines? This is not indicated in the lesson text.
I can understand your confusion b/c the instructions don’t specifically say to paste the code in the
script.py tab. Maybe reset this particular lesson and paste the code again to see if that resolves the issue(?)
If you’re using Jupyter Notebook or Colab, no you don’t need a
(or whatever you want to see)
The default for using
.head() is the first five rows of a dataframe.
If you want to see the last 5 rows of a dataframe, you can type:
You can also do:
df.info() which will tell you the data types in the df
df.shape() which will tell you how many rows/cols you have
df.isnull().sum() which will tell you if you have any nulls in your df.
But that was more than you initially asked.
Please include a link to the lesson in future, they can often be tricky to find.
There are a few steps to complete on this page and this is not the first step. It may be that skipping ahead has caused an issue as any errors might prevent code execution. Try resetting the lesson (just this lesson) and completing the instructions in order. You should end up with three different
script.py file to indicate where they should be added.
a = 3 print(a) # This is fine. print(b) # A NameError would occur here since b has not yet been assigned. b = 10
I’ve not seen any form of interactive Python interpreter on CC yet, best to be adding output values explicitly, even if it’s just wrapping
Much appreciated, thank you for such a comprehensive answer!
Okay interesting, thank you!
This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.