Mode chart issue

Screen Link: Learn data science with Python and R projects

My Code:

houses['Mo Sold'].plot.kde(xlim=[1,12])

import matplotlib.pyplot as plt

plt.axvline(houses['Mo Sold'].mode()[0], color='Green', label= 'Mode')
plt.axvline(houses['Mo Sold'].median(), color='Orange', label='Median')
plt.axvline(houses['Mo Sold'].mean(), color = 'Black', label = 'Mean')
plt.legend()

Why it is 0 in plt.axvline(houses[‘Mo Sold’].mode()[0], color=‘Green’, label= ‘Mode’)? mode is 0 6 so i put plt.axvline(houses[‘Mo Sold’].mode()[1], color=‘Green’, label= ‘Mode’) then cause error…

Hi @ipngasi,

In this example, the mode is not 0 6. The mode here is the only value, and it’s 6.

If you run type(houses['Mo Sold'].mode()), you’ll see, that it’s a Series, and if you run len(houses['Mo Sold'].mode()), you’ll see that it contains only one element. This only element has the index 0, and the index 1 just doesn’t exist in this Series.

You can try also this code:

list(houses['Mo Sold'].mode())

Hi Elena,

Thank you, I understand now. Also, I want to upload the guided project to Github while I was stuck in the process. Anyone I can contact with this issue?

Best,
Jessie

Hi Jessie,

Sure. Tell me what issue you have with loading your project on GitHub, and I’ll try to help you.

Thank you Elena.

I am stuck in the process of initialize the folder as a git repository.

Here’s the guideline I follow:

My Code:

cd loans
git init

What I expected to happen:

Initialized empty Git repository in /loans/.git/

What actually happened:

no such file or dictionary
Permission denied

can you please advise is this the correct guideline to follow? if so, anything I can do to fix it(e.g. it seems Git doesn’t know where I save the folder, how can I clarify?)

Best,
Jessie

Hi Jessie,

Honestly, I’m a bit afraid of the command line, so I’m always trying to avoid using it when it’s possible :sweat_smile: For example, to create my portfolio of projects, I just opened my account on the github.com website and created there a new repository in a user-friendly way. Then, from time to time, I add new projects there or update the existing ones.

Anyway, returning to your question. For the command cd loans to run successfully, the loans folder has to be exactly in the current working directory (to check the path to your current working directory, you should run the command pwd). If the loans folder is in another folder, then you have to specify the whole path to it. Otherwise yes, Git doesn’t know where to go to look for this folder.


Hi Elena,

Thank you for your response. I’m not sure I did it right or not, i’ve edit the previous file that I created several weeks before. But why it doesn’t show the first 10 rows like the guided project answer?? anything I need to connect the dataset??

Best,
Jessie

Hi Jessie,

It seems that you’ve just updated the README.md file instead of uploading your ipynb project on Star Wars Survey. The README.md file serves to describe what is inside your project or repository, but it doesn’t substitute the project itself (meaning that you shouldn’t insert any code or results in it). Instead, you should open your repository Star Wars Survey, then select Add file, then Upload files, select the project notebook from your computer and upload it.

Hi Elena,

I have uploaded the ipynb notebook file and here’s the parmalink

It hasy code now but doesn’t show like the guide project answer layout, code- result.

Any settings needs to be changed?

Hi @ipngasi I’m not exactly sure why/how but it appears your file was uploaded as a *.json file and not a *.ipynb file. Make sure the file you’re selecting to upload from your local machine as the correct ipynb file extension and try again. I found this article on StackOverflow and apparently this file extension confusion is quite common.

I think it’s successful now. ^^

Here’s the another project I just create in another repository.

Thanks a lot for both of you Mike, Elena. I’m so glad to upload successfully!!!

1 Like