Skip to content

Instantly share code, notes, and snippets.

@who-you-me
Created December 21, 2012 15:04
Show Gist options
  • Save who-you-me/4353349 to your computer and use it in GitHub Desktop.
Save who-you-me/4353349 to your computer and use it in GitHub Desktop.
# -*- coding: utf-8 -*-
import pandas as pd
from teams import teams, teams_old
col_use = ["年度", "チーム", "得点", "安打", "二塁打",
"三塁打", "本塁打", "盗塁", "盗塁刺", "犠打",
"犠飛", "四球", "死球", "三振", "併殺打"]
df = pd.read_csv("batting.csv")[col_use]
sums = df.groupby(["年度", "チーム"]).sum()
model = pd.ols(y=sums["得点"], x=sums.drop("得点", axis=1))
print model
df2012 = df[df["年度"] == 2012].groupby("チーム").sum()
print df2012.ix["c"]- df2012.mean()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment