Created
January 7, 2024 01:20
-
-
Save smzn/1d81c76f02b43e49bf6e99e5becfa7b2 to your computer and use it in GitHub Desktop.
ステーション間のトリップの回数をカウント
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ステーション間のトリップの回数をカウント | |
transition_counts = df.groupby(['start_station_name', 'end_station_name']).size().reset_index(name='transition_count') | |
# 推移回数行列の作成 | |
transition_matrix = transition_counts.pivot_table(index='start_station_name', columns='end_station_name', values='transition_count', fill_value=0) | |
# 結果を表示(上位の行のみ) | |
transition_matrix |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment