Last active
March 30, 2017 01:01
-
-
Save hitowaft/dfe864537964418a684a6f350c1e71ae 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
# coding: utf-8 | |
# In[1]: | |
import pandas as pd | |
import matplotlib.pyplot as plt | |
# In[2]: | |
tweet_df = pd.read_csv("/hoge/tweets.csv", parse_dates=["timestamp"]) #ここにダウンロードしたcsvファイルのパスを入れる | |
tweet_df = tweet_df.set_index(["timestamp"]) | |
tweet_df = tweet_df.reindex(columns=["text"]) | |
# In[3]: | |
columns = {"Yohei":"洋平|ようぺ", "Ichiro":"一郎"} #ここにグラフにしたいワードを入れる | |
for k, v in columns.items(): | |
tweet_df["{}".format(k)] = tweet_df["text"].str.contains("{}".format(v)) | |
tweet_df = tweet_df.drop(["text"], axis=1) | |
# In[4]: | |
tweet_df = tweet_df.resample("M").sum() | |
tweet_df.plot() | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment