This file contains hidden or 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
# Plot | |
Plots.plot( | |
commodities.date, | |
commodities.comm, | |
html_output_format=:png, # Important for nice printing | |
label = "All commodity prices (IMF)", | |
legend= :bottomright | |
) |
This file contains hidden or 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
# Load required packages | |
using CSV | |
using DataFrames | |
using Plots | |
using Pipe | |
using Dates | |
# Read csv | |
commodities = CSV.read("../../../Datasets/imf-commodities.csv", DataFrame); |
This file contains hidden or 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
# Plot | |
sns.lineplot( | |
data=commodities, | |
x='date', y='comm', | |
label='All commodity prices (IMF)' | |
); | |
plt.legend(loc="lower right") | |
plt.show() |
This file contains hidden or 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
# Load required libraries | |
import pandas as pd | |
import seaborn as sns | |
import matplotlib.pyplot as plt | |
# Read csv | |
commodities = pd.read_csv('../../../Datasets/imf-commodities.csv') | |
# Data wrangling | |
commodities = ( |
This file contains hidden or 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
# Plot | |
commodities %>% | |
ggplot(aes(x=date, y=comm)) + | |
geom_line(aes(color='All commodity prices (IMF)')) + | |
theme( | |
legend.position = c(.8, .1), | |
legend.title = element_blank() | |
) + | |
labs(x="", y="") + | |
scale_color_manual(values="black") |
This file contains hidden or 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
# Load required packages | |
library(tidyverse) | |
library(lubridate) | |
# Read csv | |
commodities <- read_csv('../../../Datasets/imf-commodities.csv') | |
# Tidy | |
commodities <- commodities %>% | |
select(date = Commodity, comm = PALLFNF) %>% |
This file contains hidden or 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
for i in range(1, 5): | |
print(sl_tweets.sort_values('favorites', ascending=False).head(5).reset_index().full_text[i], '\n --') |
This file contains hidden or 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
from pywaffle import Waffle | |
data = {'In favor (99)': 99/50, 'Against (7436)': 7436/50} | |
fig = plt.figure( | |
FigureClass=Waffle, | |
rows=10, | |
values=data, | |
colors=("#5b9aa0", "#e06377"), | |
title={'label': 'SupearLeague hashtags \n \n', |
This file contains hidden or 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
# Get only hashtags in favor and against the superleague: | |
against_hashtag = classified_hashtags.hashtag[classified_hashtags.label==1] | |
favor_hashtag = classified_hashtags.hashtag[classified_hashtags.label==3] | |
# Filter against hashtags among all hashtags (to get the count of each one) | |
no_hashtags = [x for x in hashtags if x in list(against_hashtag)] | |
# Get top10 hashtags | |
top10_no_hashtags = list(pd.Series(no_hashtags).value_counts().head(10).index) | |
sl_tweets = (sl_tweets | |
.assign(against=lambda y: [any(x in sublist for x in against_hashtag) | |
for sublist in y.hashtags], |
This file contains hidden or 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
classified_hashtags = pd.read_csv('unique_hashtag_clean.csv').iloc[:, 1:] | |
classified_hashtags.label.value_counts() | |
#> 2.0 8846 | |
#> 1.0 530 | |
#> 3.0 43 | |
#> Name: label, dtype: int64 |
NewerOlder