-
Notifications
You must be signed in to change notification settings - Fork 263
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
newb having some trouble #33
Comments
@roodhouse have a look at #21 and let me know if it helps. If that doesn't get you going I'm sure I can help set your environment up. |
Thank you. Not sure what it did. But now when I try to run nfldb-update it says 'nfldb-update' is not recongizned as an internal or external command, operable program or batch file." I first ran it as python nfldb-update and got the same message.. Thank you for walking me through this. |
and I am using Windows.. |
Based on your answer to the question you reference I tried : C:\Python27\Scripts> pip install nfldb It did a few things but ended with "ImportError: No module named _vendor" Am I missing files? I downloaded a bunch of stuff, so forgive me if I missed something obvious. |
Can you open Python IDLE (it is an interactive interpreter) and try typing:
And hit enter. Does it work? If so, then nfldb is installed. If nfldb-update can't be found, then either nfldb is not installed or you are experiencing PATH issues. @ochawkeye I think nfldb-update should end up in the bin or scripts directory? |
The pytz error means you haven't installed nfldb's dependencies. If you installed nfldb via pip, then this should have been done automatically. I have no idea what that pip error means. It's almost as if your pip install is borked, which is very troubling. |
From Python I get "ImportError: No module named pytz" I see nfldb-update in scripts folder for python. |
If you're completely lost, I would suggest removing all Python stuff on your machine and starting over. Focus on installing pip and getting 'pip install nfldb' to work. Installing the Python code should be the easiest part, compared to setting up the database. :( |
Can you run nfldb-update from inside the scripts directory? |
How did you install nfldb if pip isn't working for you? |
tell me how to install nfldb via pip and I can tell you if I did it. I really don't remember and starting over is something I have been coming back to. I cant run nfldb from anywhere at this point. I have no idea how installed if pip wasn't working. |
everything was rolling until after this step... nfldb=# \d I saw that message in my prompt. Since then I have been lost.. |
If pip is installed, then follow the instructions here: https://github.com/BurntSushi/nfldb/wiki/Windows-Install These look like decent instructions for installing pip: https://pip.pypa.io/en/latest/installing.html |
@ochawkeye Windows is really annoying. Do you know of any way to bundle everything up into one executable? |
I am sorry, but I have been on those websites for the past 4 hours. I thought I followed the instructions correctly... |
Thinks went askew for me on step 12 of the windows install page you linked |
You aren't really on step 12 though because nfldb just isn't properly installed. It seems like you got the database setup, which is great and usually the most difficult part. I'm not sure how else I can help you with the detail you've given so far. If you start over, I'd suggest keeping a more detailed record of the steps you went through and what exactly went wrong. I know it's frustrating, but the Python experience on Windows is unfortunately pretty grim. |
No worries. I will start over. Uninstall everything I installed yesterday. Keep notes Thanks for yall's help! On Tue, Jul 29, 2014 at 10:44 PM, Andrew Gallant notifications@github.com
|
Apologies for offering to help and then promptly falling asleep - ah, the life of someone with a ~2 year old. Nuking it and starting over is an extreme step and I'm pretty sure we could get you going with what you have. But my schedule is kind of booked this morning for the next 6 hours or so. If you do start over and arrive at the same problem, we can have a TeamViewer session for me to review your environment. |
@ochawkeye is awesome. :D |
HA! 2 kids under 3.5 and a 7 month pregnant wife here. All 3 girls. I am currently nuking it, but I will be in touch again later today. If I Thanks man! On Wed, Jul 30, 2014 at 6:59 AM, Andrew Gallant notifications@github.com
|
A couple of things I would be interested in reviewing: Do the following commands from a command prompt do the same thing for you?
Same question for pip:
What version of Python are you running? (From my example above you can see I have Python 2.7.6 32 bit) |
I’m also a novice and struggled a bit. But I found that installing with pip to be key.
Also I reverted to Ochawkeye’s tutoring here,
Good luck. |
@teamfball thank you, I will take a look. @ochawkeye, when I get to that point in my reinstalls I will see if those Before I do anything else though..... Do I need nflgame up and running in order to have nfldb up and running? On Wed, Jul 30, 2014 at 7:22 AM, ochawkeye notifications@github.com wrote:
|
@roodhouse If you're using |
@roodhouse Man I feel for you. Frozen has already been played twice beginning to end here and it's not even 10am. And I only have one girl. 2 month old son can't grow up fast enough for me 👪 |
frozen. do you want to build a snowman? ride your bike around the hall? I am done with the windows install page. I am going to copy my notes As you can see I have the same result.. On Wed, Jul 30, 2014 at 9:54 AM, ochawkeye notifications@github.com wrote:
Windows Install
|
all attaching did was paste my notes here.. sorry about that.. I am waiting instruction now.. |
Looks like you've installed
|
just tried this with this result: c:\Python27\Scripts>python pip.exe install nfldb and what you suggested with this result: c:\Python27\Scripts>python pip.exe install nfldb |
wait.. no it is not... it is w/in pip.. sorry |
I'm available for a TeamViewer session if you have time. |
how long will you be available for? i have to run out real quick.. |
nevermind, lets do it |
email sent.. |
awesome. @ochawkeye thank you! |
@roodhouse Got it? Yay! @ochawkeye I am fiercely curious what the issue was... |
@BurntSushi T'was a rouge file named 'pip.py' in the Python execution folder. I guess that file was being given preferential treatment over the actual *not that I ever did that when I first started playing with nflgame and it took me two days to figure out what the heck was wrong with your "junk" python code |
@ochawkeye Ah ha! Nice find. Yeah, 99% of all Python problems are due to its insane import resolution semantics. Gah. One reason to move to Python 3 is that |
I only hope the frustration of the past couple of days hasn't scared away @roodhouse! |
First of all, thanks so much for putting this together, this is some amazing stuff, and I've wanted to work with data like this for a while now. Hey, I'm reading this now, and I'm basically in the same predicament. I have gotten the nfldb db loaded in postgresql (for ease, I'll call it SQLnfldb), but may be issues with the python nfldb (PYTnfldb). I got the get-pip.py file downloaded and I ran it. I thought it installed okay, but when I tried to run the test example I get an empty space
I tried pressing through this (I wasn't sure if this was an error or not), and when I ran
It seems to work okay for 2012 one time, but since then, I get nothing. I just wanted to confirm if I should be seeing the "Query object at 0x0#######" or if that's a sign that something is wrong, or if there's another issue in play. Thanks again. |
Strings in Python are case sensitive, so you need to watch out for that Running this code: import nfldb
db = nfldb.connect()
q = nfldb.Query(db)
q.game(season_year=2013, season_type='Regular')
for pp in q.sort('passing_yds').limit(10).as_aggregate():
print pp.player, pp.passing_yds should give you this result:
Changing that one character in my code: import nfldb
db = nfldb.connect()
q = nfldb.Query(db)
q.game(season_year=2013, season_type='regular')
for pp in q.sort('passing_yds').limit(10).as_aggregate():
print pp.player, pp.passing_yds now gives me a Python error:
Is this what you're seeing? |
No... It's going through. It just seems to be... empty. I just restarted IDLE I did this:
And got this message: <nfldb.query.Query object at 0x03518030> I then ran
and got the same results as you But now, when I ran
underneath, I got a blank (usually I had been hitting enter and then seeing results), and then (>>>) |
I guess I haven't asked what I suppose should be an obvious question, do I need to re-enter import nfldb every time? And again, thanks to yourself and burntsushi, this is super fun stuff. |
Ahhh...I'm beginning to understand. The IDLE shell has it's uses, but it is not much more than a learning tool for Python. Try clicking But you don't really need IDLE to do any of this. With that same file you just created (which you could have created with the text editor of your preference), you can fire up a command prompt and enter the following:
|
I think you just asked a question asked by every beginner programmer. The answer, of course, is a resounding NO! That's probably why you're doing this in the first place. Sure, you could look up each of the yardage totals for each of those QBs on NFL.com and create the table yourself - or you could have the Python code do the work for you. If you find yourself typing redundant code over and over again, there is a good chance you could be consolidating that in to a much more succinct set of instructions. Say you wanted to find out who led the league in passing in 2013, 2012, and 2011. You could always go the route of copying and pasting your working example above, changing the import nfldb
db = nfldb.connect()
q = nfldb.Query(db)
q.game(season_year=2013, season_type='Regular')
for pp in q.sort('passing_yds').limit(10).as_aggregate():
print pp.player, pp.passing_yds
print '-'*79
q = nfldb.Query(db)
q.game(season_year=2012, season_type='Regular')
for pp in q.sort('passing_yds').limit(10).as_aggregate():
print pp.player, pp.passing_yds
print '-'*79
q = nfldb.Query(db)
q.game(season_year=2011, season_type='Regular')
for pp in q.sort('passing_yds').limit(10).as_aggregate():
print pp.player, pp.passing_yds There sure is a lot of code that is written and rewritten again and again there. It could easy be re-factored into the following: import nfldb
db = nfldb.connect()
def top_10_qb_passing_yds(db, yr):
q = nfldb.Query(db)
q.game(season_year=yr, season_type='Regular')
for pp in q.sort('passing_yds').limit(10).as_aggregate():
print pp.player, pp.passing_yds
for year in [2013, 2012, 2011]:
top_10_qb_passing_yds(db, year)
print '-'*79 I see now that there is another way to interpret your question. The answer to that version is: Do I need to re-enter <> every time?: |
On the other hand, if you're doing more/different stuff with the same query, then no, you don't need to re-enter the top lines every time. For example, if I'm doing multiple sorts of the same data pulled from the database, then I only need pull the data from the database the one time. The following is perfectly valid code. import nfldb
db = nfldb.connect()
q = nfldb.Query(db)
q.game(season_year=2013, season_type='Regular')
for pp in q.sort('passing_yds').limit(3).as_aggregate():
print pp.player, pp.passing_yds
print '-'*79
for pp in q.sort('rushing_yds').limit(3).as_aggregate():
print pp.player, pp.rushing_yds
print '-'*79
for pp in q.sort('receiving_yds').limit(3).as_aggregate():
print pp.player, pp.receiving_yds
|
I was about to ask was the 'print '-'*79 was, then I ran it and realized it was a separator. I have another question, which may be something that's a totally different "issue", or an answer or already exists When I ran that top 10 QBs for 2012 I got this result in the 10
Thanks again. |
What does it say if you try to
Notice the line
|
Huh... now I get an error message 'pip' is not a recognized as an internal or external command. last time, I installed by doing python pip.exe install nfldb (or maybe pip.exe install nfldb) but from the directory of c:\python27\Scripts I tried doing it from that directory and it worked, the first 5 were the same as yours, but I didn't have the httplib or beautifulsoup lines. |
Interesting question and one I'm not immediately able to provide an answer for. Of course, it can be a complex scenario with what you call a player that ends up hopping from team to team to team, but truth is that import nfldb
db = nfldb.connect()
q = nfldb.Query(db)
q.game(season_year=2012, season_type='Regular')
q.play_player(team='TB')
for pp in q.sort('passing_yds').limit(3).as_aggregate():
print '%s - %s yards passing' % (pp.player, pp.passing_yds)
for pp in q.sort('rushing_yds').limit(3).as_aggregate():
print '%s - %s yards rushing' % (pp.player, pp.rushing_yds)
for pp in q.sort('receiving_yds').limit(3).as_aggregate():
print '%s - %s yards receiving' % (pp.player, pp.receiving_yds)
I'm sure @BurntSushi can give a thorough explanation. |
Re: 'pip' is not a recognized as an internal or external command Just need to add |
@iliketowel With regards to the team for Josh Freeman. This gets a bit hairy. Here is a central truth about the data in With that said, every individual statistic for a player also has a team attached to it. This is historical data, so that the proper team for every player stays fixed. So that means, if you're listing individual play statistics, you can always print the right team. For example: import nfldb
db = nfldb.connect()
q = nfldb.Query(db)
q.game(season_year='2012', season_type='Regular', week=1)
q.player(full_name='Josh Freeman')
q.play_player(passing_yds__ge=15)
for pp in q.as_play_players():
print pp.player.full_name, pp.team, pp.passing_yds And the output:
Notice that the team is outputted as Now, finally, we can get to your particular example. It is difficult because you are aggregating results over a season. A player doesn't necessarily have the same team over a season, so when you aggregate statistics, the import nfldb
db = nfldb.connect()
q = nfldb.Query(db)
q.game(season_year='2012', season_type='Regular')
q.sort('passing_yds').limit(10)
for pp in q.as_aggregate():
print pp.player.full_name, pp.team, pp.passing_yds And now the output: [andrew@Liger nfldb] python2 33.py
Drew Brees None 5177
Matthew Stafford None 4965
Tony Romo None 4903
Tom Brady None 4799
Matt Ryan None 4719
Peyton Manning None 4667
Andrew Luck None 4374
Aaron Rodgers None 4303
Josh Freeman None 4065
Carson Palmer None 4018 That's not very nice, so therefore, the example takes an easier path: it just shows you the team that the player currently belongs to. If you'd like to tumble down the rabbit hole and fix this for real, then you need to find all teams that a player played for. There are lots of ways to do this, but basically, you'd want to find all the individual plays and accrue all unique teams in those plays for that player. For example, last year, Trent Richardson played on a couple teams. We could discover this by looking at the import nfldb
db = nfldb.connect()
q = nfldb.Query(db)
q.game(season_year='2013', season_type='Regular')
q.player(full_name='Trent Richardson')
teams = set()
for pp in q.as_play_players():
teams.add(pp.team)
print ', '.join(teams) And that outputs:
Just as you'd expect. |
Thanks again. I figured out the other issue I was having. Because I installed NFLGame first, I didn't use pip at the time. I did it on a different computer and after some minor issues (I'm finding issues with trying to install when using PostGRESQL 64 bit version), I was able to get this up and running. For now I'm mostly playing with this data in the POSTGRESQL DB GUI, and because I work in visual analytics I'm trying to create fun and interesting visualizations out of the information. I may end up putting some of this stuff up on Tableau (and Tableau Public), but I'd like to confirm how/if you want to be credited. For now, I added fields to confirm direction of the play, and whether it was in shotgun. I'm also working to see if I can figure out a way to see how players doing against starters in preseason (to see if there is any carryover), but that's difficult to do, because there's no real way to tell when starters exit pre-season games. |
Yes, please do put things up on Tableau and share them with us when you do. :-) (Opening a new issue or adding it to the wiki is perfectly acceptable.) As far as credit goes... Having a shout out to the project (not me) is always appreciated. It helps increase awareness and hopefully attracts more folks. But of course, |
First, thank you for putting this together. I am excited about it.
However, as stated I am a newb and I've found myself lost.
I made it through the install instructions for Windows however each time a try to run either the top-ten-qbs.py or nfldb-update I get an error that says:
"ImportError: No module named pytz"
Not sure what I have done wrong or missed. Could you help me troubleshoot.
Thank you!
-John
The text was updated successfully, but these errors were encountered: