Skip to content

Instantly share code, notes, and snippets.

View Shinichi-Nakagawa's full-sized avatar

Shinichi Nakagawa Shinichi-Nakagawa

View GitHub Profile
@Shinichi-Nakagawa
Shinichi-Nakagawa / npb2023_teamstats.ipynb
Last active September 30, 2023 08:20
npb2023_teamstats.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 / npb2023_teamstats.ipynb
Created September 24, 2023 09:13
npb2023_teamstats.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 / snipet_pyspark_02.py
Last active November 8, 2022 08:11
PyCon JP 2022資料用スニペット
"""
5. BigQuery読込
"""
from pyspark.sql import SparkSession
from pyspark.sql import DataFrame as SparkDataFrame
from pyspark.sql.utils import AnalysisException
# ここは同じ
spark: SparkSession = SparkSession \
@Shinichi-Nakagawa
Shinichi-Nakagawa / snipet_pyspark_01.py
Last active October 14, 2022 15:31
PyCon JP 2022資料用のスニペット
"""
1. Sessionを作る
"""
from pyspark.sql import SparkSession
# BigQueryを使う&Stringの範囲を広げる
spark: SparkSession = SparkSession \
.builder \
.appName(‘app_yakiu')\
@Shinichi-Nakagawa
Shinichi-Nakagawa / csv2bq.py
Last active July 10, 2022 07:34
DataprocでBaseball savantデータを集計する(保存済みのCSVがGCSにあったとして)
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 December 9, 2020 01:55
得点期待値サンプル - Streamlit
import streamlit as st
# numpyとpandasを使います. 計算はほぼpandas
import csv
import numpy as np
import pandas as pd
st.write('# 得点期待値をPythonで算出するサンプル')
st.write('## データ読み込みと下処理')
@Shinichi-Nakagawa
Shinichi-Nakagawa / sample_pyspark.ipynb
Created November 27, 2019 15:12
PySpark検証サンプル
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 November 17, 2019 06:06
ミッキー・マントル(MLB)のOPS推移とパフォーマンス軌跡 - Python版
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 November 17, 2019 06:04
ミッキー・マントル(MLB)のOPS推移とパフォーマンス軌跡
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 January 31, 2018 08:15
ダルビッシュ有の2017年投球データをかるーく可視化する
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.