-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2e32d6a
commit b70b44a
Showing
15 changed files
with
346 additions
and
62 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Binary file not shown.
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
6 changes: 6 additions & 0 deletions
6
..._data-jvsc-af2aac77-8247-4b31-ad08-58debbe381c8f9addc45-fb43-472e-949a-2113dfa9a482.ipynb
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"cells": [], | ||
"metadata": {}, | ||
"nbformat": 4, | ||
"nbformat_minor": 5 | ||
} |
Empty file.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,10 @@ | ||
from functions import * | ||
from variables import * | ||
from classes import * | ||
from classes.extract_data import * | ||
from classes.create_df import * | ||
from functions import * | ||
|
||
obj = Create_df() | ||
|
||
# get_all_tweets(files, start_date, max_results, tweet_fields, expansions) | ||
df_list = [obj.tweet_df, obj.author_df] | ||
|
||
Extract_data() | ||
create_database(df_list) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
from classes.extract_data import * | ||
import pandas as pd | ||
|
||
class Create_df: | ||
|
||
obj = Extract_data() | ||
|
||
data_1 = obj.response_json_1 | ||
data_2 = obj.response_json_2 | ||
|
||
retweet_count_list = [] | ||
reply_count = [] | ||
like_count = [] | ||
quote_count = [] | ||
|
||
df_tweet_1 = pd.DataFrame() | ||
df_tweet_2 = pd.DataFrame() | ||
df_tweet_list = [df_tweet_1, df_tweet_2] | ||
|
||
df_author_1 = pd.DataFrame() | ||
df_author_2 = pd.DataFrame() | ||
df_author_list = [df_author_1, df_author_2] | ||
|
||
def __init__(self): | ||
self.data_list = [self.data_1, self.data_2] | ||
|
||
self.main_tweet_df() | ||
self.main_author_df() | ||
self.drop_columns() | ||
self.get_detail_list() | ||
self.add_lists_to_df() | ||
|
||
|
||
def main_tweet_df(self): | ||
for index, data in enumerate(self.data_list): | ||
data = data['data'] | ||
self.df_tweet_list[index] = pd.DataFrame(data) | ||
self.tweet_df = pd.concat(self.df_tweet_list) | ||
|
||
|
||
def main_author_df(self): | ||
for index, data in enumerate(self.data_list): | ||
data = data['includes']['users'] | ||
self.df_author_list[index] = pd.DataFrame(data) | ||
self.author_df = pd.concat(self.df_author_list) | ||
|
||
|
||
def drop_columns(self): | ||
self.tweet_df.drop(columns='public_metrics', axis=1, inplace=True) | ||
self.tweet_df.drop(columns='edit_history_tweet_ids', axis=1, inplace=True) | ||
|
||
|
||
def get_detail_list(self): | ||
for data in self.data_list: | ||
for tweet in data['data']: | ||
self.retweet_count_list.append(tweet['public_metrics']['retweet_count']) | ||
self.reply_count.append(tweet['public_metrics']['reply_count']) | ||
self.like_count.append(tweet['public_metrics']['like_count']) | ||
self.quote_count.append(tweet['public_metrics']['quote_count']) | ||
|
||
|
||
def add_lists_to_df(self): | ||
self.tweet_df['retweet_count'] = self.retweet_count_list | ||
self.tweet_df['reply_count'] = self.reply_count | ||
self.tweet_df['like_count'] = self.like_count | ||
self.tweet_df['quote_count'] = self.quote_count | ||
|
||
|
||
|
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
Oops, something went wrong.