Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Please HELP!
#1
Hey all!!

I am having so much trouble with running a code for my project in Statistics.

My teacher referred me to this site, seems like he doesn't know whats going on either. I am extremely frustrated!

I am using Codio for Python and the project is about compiling data for two basketball teams. I need to run codes to get the mean, median, variance, standard deviation.

The codio gives us step by step of what to do, having most of the codes prefilled, just leaving out some things. When i run the code it says "name is not defined" and its silly because it doesn't say in the steps to even touch that portion of the code. I dont know what to do i am ready to pull my hair out. Is there a way someone could message me or email me please please please!
I understand statistics, but python is a whole foreign language for me and I dont get why the class would be mostly on python when the teach doesn't seem to understand :(

-------------------------------------------

Here are the only steps it wants us to do:

Replace ??MEAN_FUNCTION?? with the name of Python function that calculates the mean.
Replace ??MEDIAN_FUNCTION?? with the name of Python function that calculates the median.
Replace ??VAR_FUNCTION?? with the name of Python function that calculates the variance.
Replace ??STD_FUNCTION?? with the name of Python function that calculates the standard deviation.
-------------------------------------------




Here is the steps I put into the mostly prefilled code:

print("Your Team's Relative Skill in 2013 to 2015")
print("-------------------------------------------------------")

# ---- TODO: make your edits here ----
mean = you_team_df['elo_n'].mean()
median = your_team_df['elo_n'].median()
variance = your_team_df['elo_n'].variance()
stdeviation = your_team_df['elo_n'].stdev()
print('Mean =', round(mean,2))
print('Median =', round(median,2))
print('Variance =', round(variance,2))
print('Standard Deviation =', round(stdeviation,2))




--------------------------
Here is the error I continue to get:
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
<ipython-input-15-b7e20510d8d4> in <module>
3
4 # ---- TODO: make your edits here ----
----> 5 mean = you_team_df['elo_n'].mean()
6 median = your_team_df['elo_n'].median()
7 variance = your_team_df['elo_n'].variance()

NameError: name 'you_team_df' is not defined
Reply
#2
Hey all!!

I am having so much trouble with running a code for my project in Statistics.

My teacher referred me to this site, seems like he doesn't know whats going on either. I am extremely frustrated!

I am using Codio for Python and the project is about compiling data for two basketball teams. I need to run codes to get the mean, median, variance, standard deviation.

The codio gives us step by step of what to do, having most of the codes prefilled, just leaving out some things. When i run the code it says "name is not defined" and its silly because it doesn't say in the steps to even touch that portion of the code. I dont know what to do i am ready to pull my hair out. Is there a way someone could message me or email me please please please!
I understand statistics, but python is a whole foreign language for me and I dont get why the class would be mostly on python when the teach doesn't seem to understand :(

-------------------------------------------

Here are the only steps it wants us to do:

Replace ??MEAN_FUNCTION?? with the name of Python function that calculates the mean.
Replace ??MEDIAN_FUNCTION?? with the name of Python function that calculates the median.
Replace ??VAR_FUNCTION?? with the name of Python function that calculates the variance.
Replace ??STD_FUNCTION?? with the name of Python function that calculates the standard deviation.
-------------------------------------------




Here is the steps I put into the mostly prefilled code:

print("Your Team's Relative Skill in 2013 to 2015")
print("-------------------------------------------------------")

# ---- TODO: make your edits here ----
mean = you_team_df['elo_n'].mean()
median = your_team_df['elo_n'].median()
variance = your_team_df['elo_n'].variance()
stdeviation = your_team_df['elo_n'].stdev()
print('Mean =', round(mean,2))
print('Median =', round(median,2))
print('Variance =', round(variance,2))
print('Standard Deviation =', round(stdeviation,2))
--------------------------
Here is the error I continue to get:
---------------------------------------------------------------------------
Error:
NameError Traceback (most recent call last) <ipython-input-15-b7e20510d8d4> in <module> 3 4 # ---- TODO: make your edits here ---- ----> 5 mean = you_team_df['elo_n'].mean() 6 median = your_team_df['elo_n'].median() 7 variance = your_team_df['elo_n'].variance() NameError: name 'you_team_df' is not defined
Reply
#3
(Jan-23-2020, 01:14 AM)kolwelter18 Wrote: When i run the code it says "name is not defined" and its silly

As a rule computers don't do silly things. They do exactly what you tell them and in this case it is telling you exactly why it can't do it. If you are calling something called you_team_df you have to tell it what that is.

I assure you, no one here is going to do your homework and send it to you. I for one have a dozen other broken projects of my own I'd rather work on.

[/quote]

This,mean = you_team_df['elo_n'].mean() ignoring the ['elo_n'], because I don't know what that is, tells me that .mean() is a method or sub-function of something called you_team_df.

Your project is expecting you to make something like this to contain all your equations:

#not actual code
def you_team_df():

    def mean():
       math stuff

    def median():
       math stuff

    etc....
That's what the "." means. Each "." means you are moving one level deeper into a class or function.

So rather than getting frustrated, I would suggest looking at your course material from the start and making sure you know what each word means. It's a language, as you said, and there's no point in writing a screenplay if you don't know the vocabulary.

And go back and delete you duplicate posts. You won't get more help my annoying people.
Reply
#4
your_team_df is supposedly pandas data frame that will hold some data that you will use to calculate different statistics. I would guess it should be either created by someone in advance (before that part of the code you show) or you should create it with some dummy data
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#5
(Jan-23-2020, 02:58 AM)michael1789 Wrote:
(Jan-23-2020, 01:14 AM)kolwelter18 Wrote: When i run the code it says "name is not defined" and its silly
As a rule computers don't do silly things. They do exactly what you tell them and in this case it is telling you exactly why it can't do it. If you are calling something called you_team_df you have to tell it what that is. I assure you, no one here is going to do your homework and send it to you. I for one have a dozen other broken projects of my own I'd rather work on.
This,mean = you_team_df['elo_n'].mean() ignoring the ['elo_n'], because I don't know what that is, tells me that .mean() is a method or sub-function of something called you_team_df. Your project is expecting you to make something like this to contain all your equations:
 #not actual code def you_team_df(): def mean(): math stuff def median(): math stuff etc.... 
That's what the "." means. Each "." means you are moving one level deeper into a class or function. So rather than getting frustrated, I would suggest looking at your course material from the start and making sure you know what each word means. It's a language, as you said, and there's no point in writing a screenplay if you don't know the vocabulary.
And go back and delete you duplicate posts. You won't get more help my annoying people.[/quote]

Im not asking for someone to do my homework. Learning python isnt what my homework is about it is just an added program to use to put data sets together. You dont need to be rude. Dont reply in the first place.............
Reply
#6
It looks to me that you have not defined you_team_df, which by convention is a Pandas dataframe. Would need to see more of your code to verify.
Reply
#7
I think it's just a typo. "you_team_df" is supposed to be "your_team_df".
"So, brave knights, if you do doubt your courage or your strength, come no further, for death awaits you all with nasty, big, pointy teeth!" - Tim the Enchanter
Reply
#8
After correcting you_team_df to your_team_df, what is the next error?
Reply
#9
I might be late replying, but hopefully this helps others.
*Hint*
In order to get the correct output for the step 6 code. You must go through steps 1 and two and pull ot the proper code lines from those code boxes which once applied into code box 6 will exicute and result the desired outcome.
I hope this helps others, I had to just figure it out on my own.
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020