Skip to content

Commit

Permalink
Fix sql issues
Browse files Browse the repository at this point in the history
  • Loading branch information
nathanbraun committed Apr 14, 2023
1 parent a5d6d68 commit 3bd89db
Show file tree
Hide file tree
Showing 8 changed files with 3,373 additions and 2,905 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ If I were using Windows, it might look like this:
Set these aside for now and we'll pick them up in chapter 2.

## Changelog
### v0.0.7 (2023-04-14)
Fixed end of chapter sql problems (you're the man Emil!).

### v0.0.6 (2023-03-23)
Fix some misc typos, mostly in end of chapter problems (thanks again Emil!).

Expand Down
4 changes: 2 additions & 2 deletions code/04_sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
"""
SELECT player_id, name, nationality, pos, team
FROM player
WHERE team = 'CHI' AND pos == 'LW'
WHERE team = 'CHI' AND pos = 'LW'
""", conn)
df.head()

Expand All @@ -74,7 +74,7 @@
"""
SELECT player_id, name, nationality, pos, team
FROM player
WHERE team = 'BOS' OR pos == 'LW'
WHERE team = 'BOS' OR pos = 'LW'
""", conn)
df.head()

Expand Down
2,334 changes: 1,167 additions & 1,167 deletions data/problems/combine2/c.csv

Large diffs are not rendered by default.

2,162 changes: 1,081 additions & 1,081 deletions data/problems/combine2/d.csv

Large diffs are not rendered by default.

1,304 changes: 652 additions & 652 deletions data/problems/combine2/lw.csv

Large diffs are not rendered by default.

464 changes: 463 additions & 1 deletion data/problems/combine2/rw.csv

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion solutions-to-exercises/03_pandas_answers.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,19 +342,22 @@
df_fo = pd.read_csv(path.join(DATA_DIR, 'problems/combine1', 'fo.csv'))
df_poss = pd.read_csv(path.join(DATA_DIR, 'problems/combine1', 'poss.csv'))
df_shot = pd.read_csv(path.join(DATA_DIR, 'problems/combine1', 'shot.csv'))
df_hit = pd.read_csv(path.join(DATA_DIR, 'problems/combine1', 'hit.csv'))

# b
df_comb1 = pd.merge(df_name, df_fo, how='left')
df_comb1 = pd.merge(df_comb1, df_poss, how='left')
df_comb1 = pd.merge(df_comb1, df_shot, how='left')
df_comb1 = pd.merge(df_comb1, df_hit, how='left')

df_comb1 = df_comb1.fillna(0)

# c
df_comb2 = pd.concat([df_name.set_index(['player_id', 'game_id']),
df_fo.set_index(['player_id', 'game_id']),
df_poss.set_index(['player_id', 'game_id']),
df_shot.set_index(['player_id', 'game_id'])], join='outer',
df_shot.set_index(['player_id', 'game_id']),
df_hit.set_index(['player_id', 'game_id'])], join='outer',
axis=1)

df_comb2 = df_comb2.fillna(0)
Expand Down
2 changes: 1 addition & 1 deletion solutions-to-exercises/04_sql_answers.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,6 @@
player AS p
WHERE
t.team = pg.team AND
t.division = 'Central' AND
team.division = 'Atlantic' AND
p.player_id = pg.player_id
""", conn)

0 comments on commit 3bd89db

Please sign in to comment.