Example #1
0
    def _try_get_player_id(self, query_string):
        """
        Given a query string, convert it to its expected format and find the
        corresponding player id, if any.

        Arguments:
        query_string -- string, player name expected, but not guaranteed to be
            in "First Last" format

        Returns:
        Extracted query string, or None, with closest matching canonical name
        """
        try:
            first_name, last_name = query_string.split(" ")
            expected_name = "%s, %s" % (last_name, first_name)
            closest_matches = difflib.get_close_matches(expected_name,
                                                        self._get_all_player_names())
            if closest_matches:
                player_name = closest_matches[0]
                return nba.get_player_id(player_name)[0], player_name
            return None, None
        except ValueError:
            return None, None
        except:
            print "Unexpected error:", sys.exc_info()[0]
            raise
Example #2
0
    def _try_get_player_id(self, query_string):
        """
        Given a query string, convert it to its expected format and find the
        corresponding player id, if any.

        Arguments:
        query_string -- string, player name expected, but not guaranteed to be
            in "First Last" format

        Returns:
        Extracted query string, or None, with closest matching canonical name
        """
        try:
            first_name, last_name = query_string.split(" ")
            expected_name = "%s, %s" % (last_name, first_name)
            closest_matches = difflib.get_close_matches(
                expected_name, self._get_all_player_names())
            if closest_matches:
                player_name = closest_matches[0]
                return nba.get_player_id(player_name)[0], player_name
            return None, None
        except ValueError:
            return None, None
        except:
            print "Unexpected error:", sys.exc_info()[0]
            raise
Example #3
0
from django.http import HttpResponse

from django.shortcuts import render
import matplotlib.pyplot as plt
import seaborn as sns
import pandas as pd
import nbashots as nba

curry_id = nba.get_player_id("Curry, Stephen")[0]
# print(curry_id)
# curry_shots_df = nba.Shots(curry_id).get_shots()
# plt.rcParams['figure.figsize'] = (12, 11)
# nba.shot_chart(curry_shots_df.LOC_X, curry_shots_df.LOC_Y, kind='hex', gridsize=100,
#               title="Stephen Curry FGA 2015-16 Season")

# plt.show()
# Create your views here.


def index(request):
  return HttpResponse('hey')
Example #4
0
from django.http import HttpResponse

from django.shortcuts import render
import matplotlib.pyplot as plt
import seaborn as sns
import pandas as pd
import nbashots as nba

curry_id = nba.get_player_id("Curry, Stephen")[0]
# print(curry_id)
# curry_shots_df = nba.Shots(curry_id).get_shots()
# plt.rcParams['figure.figsize'] = (12, 11)
# nba.shot_chart(curry_shots_df.LOC_X, curry_shots_df.LOC_Y, kind='hex', gridsize=100,
#               title="Stephen Curry FGA 2015-16 Season")

# plt.show()
# Create your views here.


def index(request):
    return HttpResponse('hey')