Last active
October 20, 2015 18:15
-
-
Save ochawkeye/dd812022777b2734a316 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import nfldb | |
NYGmisc = {} | |
db = nfldb.connect() | |
qNYG = nfldb.Query(db) | |
for gp in qNYG.play_player(team='NYG').player(position='TE').as_aggregate(): | |
# NYGmisc[gp.player] = gp <-- if you do like this, the values are class 'nfldb.query.AggPP' | |
NYGmisc[gp.player] = {field: getattr(gp, field) for field in gp.fields} # but if you do like this they are type 'dict' | |
for x in NYGmisc: | |
print type(x), type(NYGmisc[x]) |
Author
ochawkeye
commented
Oct 20, 2015
this worked for me:
NYGmisc = { }
for gp in qNYG.play_player(team='NYG').player(position='TE').as_aggregate():
NYGmisc[gp.player] = {field: getattr(gp, field) for field in gp.fields}
for x in NYGmisc:
for y in NYGmisc[x].iteritems():
print y
@app.route("/")
def main():
return render_template('index.html',thing10=NYGmisc)
and in my index.html template:
<h4>nyg</h4>
<p> <table>
{% for key in thing10 %}
<tr>
<th> {{ key }} </th>
{% for ke in thing10[key].iteritems() %}
<td> {{ ke }} </td>
</tr>
{% endfor %}
{% endfor %}
</table> </p>
This displays the data I want.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment