mirror of
https://github.com/nprasad2077/nbaStats.git
synced 2026-11-04 09:15:35 +00:00
update models to decimal and account for null values
This commit is contained in:
BIN
Binary file not shown.
@@ -0,0 +1,148 @@
|
||||
# Generated by Django 4.2 on 2023-04-18 19:24
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('nba_data', '0001_initial'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='playerdata',
|
||||
name='AST',
|
||||
field=models.DecimalField(decimal_places=2, max_digits=5),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='playerdata',
|
||||
name='BLK',
|
||||
field=models.DecimalField(decimal_places=2, max_digits=5),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='playerdata',
|
||||
name='DRB',
|
||||
field=models.DecimalField(decimal_places=2, max_digits=5),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='playerdata',
|
||||
name='ORB',
|
||||
field=models.DecimalField(decimal_places=2, max_digits=5),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='playerdata',
|
||||
name='PF',
|
||||
field=models.DecimalField(decimal_places=2, max_digits=5),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='playerdata',
|
||||
name='PTS',
|
||||
field=models.DecimalField(decimal_places=2, max_digits=5),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='playerdata',
|
||||
name='STL',
|
||||
field=models.DecimalField(decimal_places=2, max_digits=5),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='playerdata',
|
||||
name='TOV',
|
||||
field=models.DecimalField(decimal_places=2, max_digits=5),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='playerdata',
|
||||
name='TRB',
|
||||
field=models.DecimalField(decimal_places=2, max_digits=5),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='playerdata',
|
||||
name='age',
|
||||
field=models.IntegerField(),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='playerdata',
|
||||
name='effect_fg_percent',
|
||||
field=models.DecimalField(decimal_places=3, max_digits=5),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='playerdata',
|
||||
name='field_attempts',
|
||||
field=models.DecimalField(decimal_places=2, max_digits=5),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='playerdata',
|
||||
name='field_goals',
|
||||
field=models.DecimalField(decimal_places=2, max_digits=5),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='playerdata',
|
||||
name='field_percent',
|
||||
field=models.DecimalField(decimal_places=3, max_digits=5),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='playerdata',
|
||||
name='ft',
|
||||
field=models.DecimalField(decimal_places=2, max_digits=5),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='playerdata',
|
||||
name='ft_percent',
|
||||
field=models.DecimalField(decimal_places=3, max_digits=5),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='playerdata',
|
||||
name='fta',
|
||||
field=models.DecimalField(decimal_places=2, max_digits=5),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='playerdata',
|
||||
name='games',
|
||||
field=models.IntegerField(),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='playerdata',
|
||||
name='games_started',
|
||||
field=models.IntegerField(),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='playerdata',
|
||||
name='minutes_pg',
|
||||
field=models.DecimalField(decimal_places=2, max_digits=5),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='playerdata',
|
||||
name='name',
|
||||
field=models.CharField(max_length=255),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='playerdata',
|
||||
name='three_attempts',
|
||||
field=models.DecimalField(decimal_places=2, max_digits=5),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='playerdata',
|
||||
name='three_fg',
|
||||
field=models.DecimalField(decimal_places=2, max_digits=5),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='playerdata',
|
||||
name='three_percent',
|
||||
field=models.DecimalField(decimal_places=3, max_digits=5),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='playerdata',
|
||||
name='two_attempts',
|
||||
field=models.DecimalField(decimal_places=2, max_digits=5),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='playerdata',
|
||||
name='two_fg',
|
||||
field=models.DecimalField(decimal_places=2, max_digits=5),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='playerdata',
|
||||
name='two_percent',
|
||||
field=models.DecimalField(decimal_places=3, max_digits=5),
|
||||
),
|
||||
]
|
||||
@@ -0,0 +1,23 @@
|
||||
# Generated by Django 4.2 on 2023-04-18 19:51
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('nba_data', '0002_alter_playerdata_ast_alter_playerdata_blk_and_more'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='playerdata',
|
||||
name='season',
|
||||
field=models.IntegerField(default=0),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='playerdata',
|
||||
name='team',
|
||||
field=models.CharField(default='', max_length=30),
|
||||
),
|
||||
]
|
||||
@@ -0,0 +1,18 @@
|
||||
# Generated by Django 4.2 on 2023-04-18 19:52
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('nba_data', '0003_playerdata_season_playerdata_team'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='playerdata',
|
||||
name='season',
|
||||
field=models.IntegerField(null=True),
|
||||
),
|
||||
]
|
||||
@@ -0,0 +1,148 @@
|
||||
# Generated by Django 4.2 on 2023-04-18 19:59
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('nba_data', '0004_alter_playerdata_season'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='playerdata',
|
||||
name='AST',
|
||||
field=models.DecimalField(decimal_places=2, max_digits=5, null=True),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='playerdata',
|
||||
name='BLK',
|
||||
field=models.DecimalField(decimal_places=2, max_digits=5, null=True),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='playerdata',
|
||||
name='DRB',
|
||||
field=models.DecimalField(decimal_places=2, max_digits=5, null=True),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='playerdata',
|
||||
name='ORB',
|
||||
field=models.DecimalField(decimal_places=2, max_digits=5, null=True),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='playerdata',
|
||||
name='PF',
|
||||
field=models.DecimalField(decimal_places=2, max_digits=5, null=True),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='playerdata',
|
||||
name='PTS',
|
||||
field=models.DecimalField(decimal_places=2, max_digits=5, null=True),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='playerdata',
|
||||
name='STL',
|
||||
field=models.DecimalField(decimal_places=2, max_digits=5, null=True),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='playerdata',
|
||||
name='TOV',
|
||||
field=models.DecimalField(decimal_places=2, max_digits=5, null=True),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='playerdata',
|
||||
name='TRB',
|
||||
field=models.DecimalField(decimal_places=2, max_digits=5, null=True),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='playerdata',
|
||||
name='age',
|
||||
field=models.IntegerField(null=True),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='playerdata',
|
||||
name='effect_fg_percent',
|
||||
field=models.DecimalField(decimal_places=3, max_digits=5, null=True),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='playerdata',
|
||||
name='field_attempts',
|
||||
field=models.DecimalField(decimal_places=2, max_digits=5, null=True),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='playerdata',
|
||||
name='field_goals',
|
||||
field=models.DecimalField(decimal_places=2, max_digits=5, null=True),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='playerdata',
|
||||
name='field_percent',
|
||||
field=models.DecimalField(decimal_places=3, max_digits=5, null=True),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='playerdata',
|
||||
name='ft',
|
||||
field=models.DecimalField(decimal_places=2, max_digits=5, null=True),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='playerdata',
|
||||
name='ft_percent',
|
||||
field=models.DecimalField(decimal_places=3, max_digits=5, null=True),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='playerdata',
|
||||
name='fta',
|
||||
field=models.DecimalField(decimal_places=2, max_digits=5, null=True),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='playerdata',
|
||||
name='games',
|
||||
field=models.IntegerField(null=True),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='playerdata',
|
||||
name='games_started',
|
||||
field=models.IntegerField(null=True),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='playerdata',
|
||||
name='minutes_pg',
|
||||
field=models.DecimalField(decimal_places=2, max_digits=5, null=True),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='playerdata',
|
||||
name='name',
|
||||
field=models.CharField(max_length=255, null=True),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='playerdata',
|
||||
name='three_attempts',
|
||||
field=models.DecimalField(decimal_places=2, max_digits=5, null=True),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='playerdata',
|
||||
name='three_fg',
|
||||
field=models.DecimalField(decimal_places=2, max_digits=5, null=True),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='playerdata',
|
||||
name='three_percent',
|
||||
field=models.DecimalField(decimal_places=3, max_digits=5, null=True),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='playerdata',
|
||||
name='two_attempts',
|
||||
field=models.DecimalField(decimal_places=2, max_digits=5, null=True),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='playerdata',
|
||||
name='two_fg',
|
||||
field=models.DecimalField(decimal_places=2, max_digits=5, null=True),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='playerdata',
|
||||
name='two_percent',
|
||||
field=models.DecimalField(decimal_places=3, max_digits=5, null=True),
|
||||
),
|
||||
]
|
||||
+29
-27
@@ -2,33 +2,35 @@ from django.db import models
|
||||
|
||||
# Create your models here.
|
||||
class PlayerData(models.Model):
|
||||
name = models.CharField(max_length=100)
|
||||
age = models.CharField(max_length=100)
|
||||
games = models.CharField(max_length=100)
|
||||
games_started = models.CharField(max_length=100)
|
||||
minutes_pg = models.CharField(max_length=100)
|
||||
field_goals = models.CharField(max_length=100)
|
||||
field_attempts = models.CharField(max_length=100)
|
||||
field_percent = models.CharField(max_length=100)
|
||||
three_fg = models.CharField(max_length=100)
|
||||
three_attempts = models.CharField(max_length=100)
|
||||
three_percent = models.CharField(max_length=100)
|
||||
two_fg = models.CharField(max_length=100)
|
||||
two_attempts = models.CharField(max_length=100)
|
||||
two_percent = models.CharField(max_length=100)
|
||||
effect_fg_percent = models.CharField(max_length=100)
|
||||
ft = models.CharField(max_length=100)
|
||||
fta = models.CharField(max_length=100)
|
||||
ft_percent = models.CharField(max_length=100)
|
||||
ORB= models.CharField(max_length=100)
|
||||
DRB = models.CharField(max_length=100)
|
||||
TRB = models.CharField(max_length=100)
|
||||
AST = models.CharField(max_length=100)
|
||||
STL = models.CharField(max_length=100)
|
||||
BLK = models.CharField(max_length=100)
|
||||
TOV = models.CharField(max_length=100)
|
||||
PF = models.CharField(max_length=100)
|
||||
PTS = models.CharField(max_length=100)
|
||||
name = models.CharField(max_length=255, null=True)
|
||||
age = models.IntegerField(null=True)
|
||||
games = models.IntegerField(null=True)
|
||||
games_started = models.IntegerField(null=True)
|
||||
minutes_pg = models.DecimalField(max_digits=5, decimal_places=2, null=True)
|
||||
field_goals = models.DecimalField(max_digits=5, decimal_places=2, null=True)
|
||||
field_attempts = models.DecimalField(max_digits=5, decimal_places=2, null=True)
|
||||
field_percent = models.DecimalField(max_digits=5, decimal_places=3, null=True)
|
||||
three_fg = models.DecimalField(max_digits=5, decimal_places=2, null=True)
|
||||
three_attempts = models.DecimalField(max_digits=5, decimal_places=2, null=True)
|
||||
three_percent = models.DecimalField(max_digits=5, decimal_places=3, null=True)
|
||||
two_fg = models.DecimalField(max_digits=5, decimal_places=2, null=True)
|
||||
two_attempts = models.DecimalField(max_digits=5, decimal_places=2, null=True)
|
||||
two_percent = models.DecimalField(max_digits=5, decimal_places=3, null=True)
|
||||
effect_fg_percent = models.DecimalField(max_digits=5, decimal_places=3, null=True)
|
||||
ft = models.DecimalField(max_digits=5, decimal_places=2, null=True)
|
||||
fta = models.DecimalField(max_digits=5, decimal_places=2, null=True)
|
||||
ft_percent = models.DecimalField(max_digits=5, decimal_places=3, null=True)
|
||||
ORB= models.DecimalField(max_digits=5, decimal_places=2, null=True)
|
||||
DRB = models.DecimalField(max_digits=5, decimal_places=2, null=True)
|
||||
TRB = models.DecimalField(max_digits=5, decimal_places=2, null=True)
|
||||
AST = models.DecimalField(max_digits=5, decimal_places=2, null=True)
|
||||
STL = models.DecimalField(max_digits=5, decimal_places=2, null=True)
|
||||
BLK = models.DecimalField(max_digits=5, decimal_places=2, null=True)
|
||||
TOV = models.DecimalField(max_digits=5, decimal_places=2, null=True)
|
||||
PF = models.DecimalField(max_digits=5, decimal_places=2, null=True)
|
||||
PTS = models.DecimalField(max_digits=5, decimal_places=2, null=True)
|
||||
team = models.CharField(max_length=30, default='')
|
||||
season = models.IntegerField(null=True)
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
|
||||
+8
-2
@@ -33,15 +33,19 @@ rows = table.find("tbody").find_all("tr")
|
||||
|
||||
# Extract coloumn headers
|
||||
headers = [col.text.strip() for col in header_row.find_all("th")][1:]
|
||||
headers.extend(['team', 'season']) # Add 'team' and 'season' fields to headers
|
||||
|
||||
# extract rows as dictionaries
|
||||
# Extract rows as dictionaries
|
||||
data = []
|
||||
for row in rows:
|
||||
cols = row.find_all("td")
|
||||
cols = [col.text.strip() for col in cols]
|
||||
row_dict = dict(zip(headers, cols))
|
||||
row_dict = {header: (None if col == "" else col) for header, col in zip(headers, cols)}
|
||||
row_dict['team'] = team
|
||||
row_dict['season'] = season
|
||||
data.append(row_dict)
|
||||
|
||||
|
||||
# locate current directory
|
||||
script_dir = os.path.dirname(os.path.abspath(__file__))
|
||||
|
||||
@@ -88,5 +92,7 @@ for row in data:
|
||||
TOV=row['TOV'],
|
||||
PF=row['PF'],
|
||||
PTS=row['PTS'],
|
||||
team=row['team'],
|
||||
season=row['season'],
|
||||
)
|
||||
player_data.save()
|
||||
|
||||
Reference in New Issue
Block a user