Skip to content

Instantly share code, notes, and snippets.

Avatar

Shinichi Nakagawa Shinichi-Nakagawa

View GitHub Profile
@Shinichi-Nakagawa
Shinichi-Nakagawa / csv2bq.py
Last active Jul 10, 2022
DataprocでBaseball savantデータを集計する(保存済みのCSVがGCSにあったとして)
View csv2bq.py
from datetime import datetime
import os
from pyspark.sql import SparkSession
from pyspark.sql import DataFrame as SparkDataFrame
from pyspark.sql.utils import AnalysisException
from pyspark.sql.types import StructType, StructField, DoubleType, DateType, StringType, LongType
spark = SparkSession \
.builder \
.appName('app_334')\
@Shinichi-Nakagawa
Shinichi-Nakagawa / sample_run_expectancy.py
Created Dec 9, 2020
得点期待値サンプル - Streamlit
View sample_run_expectancy.py
import streamlit as st
# numpyとpandasを使います. 計算はほぼpandas
import csv
import numpy as np
import pandas as pd
st.write('# 得点期待値をPythonで算出するサンプル')
st.write('## データ読み込みと下処理')
View sample_pyspark.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@Shinichi-Nakagawa
Shinichi-Nakagawa / mantle_career_python.ipynb
Created Nov 17, 2019
ミッキー・マントル(MLB)のOPS推移とパフォーマンス軌跡 - Python版
View mantle_career_python.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@Shinichi-Nakagawa
Shinichi-Nakagawa / mantle_career_r.ipynb
Created Nov 17, 2019
ミッキー・マントル(MLB)のOPS推移とパフォーマンス軌跡
View mantle_career_r.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@Shinichi-Nakagawa
Shinichi-Nakagawa / kwskrb056_lt_plus.ipynb
Created Jan 31, 2018
ダルビッシュ有の2017年投球データをかるーく可視化する
View kwskrb056_lt_plus.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@Shinichi-Nakagawa
Shinichi-Nakagawa / pitch_ichiro_2017.ipynb
Created Dec 31, 2017
今年のイチロー選手の全投球データを取得
View pitch_ichiro_2017.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@Shinichi-Nakagawa
Shinichi-Nakagawa / concat_mlb_data.ipynb
Created Dec 31, 2017
pitchpxで入手したデータをデータ種別毎にまとめるサンプル
View concat_mlb_data.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@Shinichi-Nakagawa
Shinichi-Nakagawa / advent-cal-sample.ipynb
Created Nov 14, 2017
Advent Calendar2017 Pythonデータラングリング by Retty
View advent-cal-sample.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@Shinichi-Nakagawa
Shinichi-Nakagawa / create_baseball_table.sql
Created Nov 5, 2017
野球データ用のTableスキーマ例
View create_baseball_table.sql
# 打撃成績
CREATE TABLE `player_batting` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`name` varchar(128) COLLATE utf8_unicode_ci DEFAULT NULL,
`number` varchar(3) COLLATE utf8_unicode_ci DEFAULT NULL,
`team` varchar(20) COLLATE utf8_unicode_ci DEFAULT NULL,
`year` int(11) DEFAULT NULL,
`date` datetime DEFAULT NULL,
`games` int(11) DEFAULT NULL,
`pa` int(11) DEFAULT NULL,