# リスト3.2.1:サンプルデータのパス
import os
base_url = (
"https://raw.githubusercontent.com/practical-jupyter/sample-data/master/anime/"
)
anime_csv = os.path.join(base_url, "anime.csv")
print(anime_csv)
https://raw.githubusercontent.com/practical-jupyter/sample-data/master/anime/anime.csv
# リスト3.2.2:ローカルデータの参照
# ローカルファイルのパスを指定 (ダウンロードした場所に応じて要変更)
anime_csv = "./anime/anime.csv"
# リスト3.2.4:anime.csvの取得
import pandas as pd
anime_csv = os.path.join(base_url, "anime.csv")
pd.read_csv(anime_csv).head()
anime_id | name | genre | type | episodes | rating | members | |
---|---|---|---|---|---|---|---|
0 | 32281 | Kimi no Na wa. | Drama, Romance, School, Supernatural | Movie | 1 | 9.37 | 200630 |
1 | 5114 | Fullmetal Alchemist: Brotherhood | Action, Adventure, Drama, Fantasy, Magic, Mili... | TV | 64 | 9.26 | 793665 |
2 | 28977 | Gintama° | Action, Comedy, Historical, Parody, Samurai, S... | TV | 51 | 9.25 | 114262 |
3 | 9253 | Steins;Gate | Sci-Fi, Thriller | TV | 24 | 9.17 | 673572 |
4 | 9969 | Gintama' | Action, Comedy, Historical, Parody, Samurai, S... | TV | 51 | 9.16 | 151266 |
# リスト3.2.5:anime_master.csvの取得
anime_master_csv = os.path.join(base_url, "anime_master.csv")
pd.read_csv(anime_master_csv).head()
anime_id | name | genre | type | episodes | rating | members | |
---|---|---|---|---|---|---|---|
0 | 32281 | Kimi no Na wa. | Drama, Romance, School, Supernatural | Movie | 1 | 9.37 | 200630 |
1 | 5114 | Fullmetal Alchemist: Brotherhood | Action, Adventure, Drama, Fantasy, Magic, Mili... | TV | 64 | 9.26 | 793665 |
2 | 28977 | Gintama° | Action, Comedy, Historical, Parody, Samurai, S... | TV | 51 | 9.25 | 114262 |
3 | 9253 | Steins;Gate | Sci-Fi, Thriller | TV | 24 | 9.17 | 673572 |
4 | 9969 | Gintama' | Action, Comedy, Historical, Parody, Samurai, S... | TV | 51 | 9.16 | 151266 |
# リスト3.2.6:anime_split_genre.csvの取得
anime_split_genre_csv = os.path.join(base_url, "anime_split_genre.csv")
pd.read_csv(anime_split_genre_csv).head()
anime_id | name | genre | type | episodes | rating | members | |
---|---|---|---|---|---|---|---|
0 | 20707 | "0" | Music | Music | 1 | 5.06 | 1170 |
1 | 25627 | "Aesop" no Ohanashi yori: Ushi to Kaeru, Yokub... | Kids | Movie | 1 | 5.00 | 113 |
2 | 7669 | "Bungaku Shoujo" Kyou no Oyatsu: Hatsukoi | Comedy | OVA | 1 | 7.06 | 14351 |
3 | 7669 | "Bungaku Shoujo" Kyou no Oyatsu: Hatsukoi | School | OVA | 1 | 7.06 | 14351 |
4 | 7669 | "Bungaku Shoujo" Kyou no Oyatsu: Hatsukoi | Fantasy | OVA | 1 | 7.06 | 14351 |
# リスト3.2.7:anime_genre_top10.csvの取得
anime_genre_top10_csv = os.path.join(base_url, "anime_genre_top10.csv")
pd.read_csv(anime_genre_top10_csv).head()
anime_id | name | genre | type | episodes | rating | members | |
---|---|---|---|---|---|---|---|
0 | 7669 | "Bungaku Shoujo" Kyou no Oyatsu: Hatsukoi | Comedy | OVA | 1 | 7.06 | 14351 |
1 | 7669 | "Bungaku Shoujo" Kyou no Oyatsu: Hatsukoi | School | OVA | 1 | 7.06 | 14351 |
2 | 7669 | "Bungaku Shoujo" Kyou no Oyatsu: Hatsukoi | Fantasy | OVA | 1 | 7.06 | 14351 |
3 | 8481 | "Bungaku Shoujo" Memoire | School | OVA | 3 | 7.54 | 18013 |
4 | 8481 | "Bungaku Shoujo" Memoire | Drama | OVA | 3 | 7.54 | 18013 |
# リスト3.2.8:anime_genre_top10_pivoted.csvの取得
anime_genre_top10_pivoted_csv = os.path.join(base_url, "anime_genre_top10_pivoted.csv")
pd.read_csv(anime_genre_top10_pivoted_csv).head()
genre | Movie | Music | ONA | OVA | Special | TV | |
---|---|---|---|---|---|---|---|
0 | Comedy | 7293127.0 | 20860.0 | 1477266.0 | 5614758.0 | 6659293.0 | 65420862.0 |
1 | Action | 10224960.0 | 77054.0 | 524907.0 | 5793680.0 | 3412689.0 | 63364032.0 |
2 | Drama | 9034099.0 | 100734.0 | 188427.0 | 3043374.0 | 1915578.0 | 41011557.0 |
3 | Romance | 5245386.0 | 42811.0 | 411331.0 | 3143167.0 | 2015820.0 | 40703388.0 |
4 | Supernatural | 5452779.0 | 9189.0 | 192989.0 | 2696715.0 | 2336723.0 | 38956520.0 |
# リスト3.2.9:anime_stock_price.csvの取得
anime_stock_price_csv = os.path.join(base_url, "anime_stock_price.csv")
pd.read_csv(anime_stock_price_csv, index_col=0, parse_dates=["Date"]).head()
TOEI ANIMATION | IG Port | |
---|---|---|
Date | ||
2015-01-01 | 3356.86 | 1201.51 |
2015-01-02 | 3356.86 | 1201.51 |
2015-01-05 | 3396.12 | 1218.44 |
2015-01-06 | 3361.77 | 1201.51 |
2015-01-07 | 3297.97 | 1202.51 |
# リスト3.2.10:anime_stock_returns.csvの取得
anime_stock_returns_csv = os.path.join(base_url, "anime_stock_returns.csv")
pd.read_csv(anime_stock_returns_csv, index_col=0, parse_dates=["Date"]).head()
TOEI ANIMATION | IG Port | |
---|---|---|
Date | ||
2015-01-01 | 1.000000 | 1.000000 |
2015-01-02 | 1.000000 | 1.000000 |
2015-01-05 | 1.011695 | 1.014082 |
2015-01-06 | 1.001463 | 1.000000 |
2015-01-07 | 0.982457 | 1.000824 |
# リスト3.2.11:4816.csvの取得
t4816_csv = os.path.join(base_url, "4816.csv")
pd.read_csv(t4816_csv, index_col=0, parse_dates=["Date"]).head()
Open | High | Low | Close | Volume | |
---|---|---|---|---|---|
Date | |||||
2010-01-04 | 1600.0 | 1600.0 | 1580.0 | 1597.0 | 5600.0 |
2010-01-05 | 1597.0 | 1605.0 | 1590.0 | 1600.0 | 14800.0 |
2010-01-06 | 1600.0 | 1602.0 | 1579.0 | 1601.0 | 8300.0 |
2010-01-07 | 1600.0 | 1600.0 | 1590.0 | 1595.0 | 3700.0 |
2010-01-08 | 1599.0 | 1601.0 | 1595.0 | 1600.0 | 32300.0 |