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
# El mejor día de la semana para vender | |
# Definir una función para calcular los rendimientos semanales | |
def weekly_returns(df): | |
# Ordenar por fecha ascendente | |
df = df.sort_values('date') | |
# Calcular el rendimiento entre cada día de la semana y el último día de la semana | |
weekly_returns = df.groupby(df['date'].dt.weekday)['price'].apply(lambda x: x.iloc[-1]/x.iloc[0]-1) | |
return weekly_returns | |
# Calcular los rendimientos semanales |
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
# El mejor día de la semana para comprar | |
# Agregar una columna al DataFrame que contenga el nombre del día de la semana correspondiente a cada fecha | |
bitcoin['day'] = bitcoin['date'].dt.day_name() | |
ethereum['day'] = ethereum['date'].dt.day_name() | |
binance['day'] = binance['date'].dt.day_name() | |
tether['day'] = tether['date'].dt.day_name() | |
usd['day'] = usd['date'].dt.day_name() | |
# Calcular la media de la columna "price" para cada día de la semana | |
btc_grouped = bitcoin.groupby('day')['price'].mean() |
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
# Convertir las fechas a formato de fechas de Pandas | |
bitcoin['date'] = pd.to_datetime(bitcoin['date']) | |
ethereum['date'] = pd.to_datetime(ethereum['date']) | |
tether['date'] = pd.to_datetime(tether['date']) | |
binance['date'] = pd.to_datetime(binance['date']) | |
usd['date'] = pd.to_datetime(usd['date']) |
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
import pandas as pd | |
import matplotlib.pyplot as plt | |
import seaborn as sns | |
import numpy as np | |
import calendar | |
# Cargar los datos desde el archivo csv | |
bitcoin = pd.read_csv('./../data/bitcoin.csv') | |
ethereum = pd.read_csv('./../data/ethereum.csv') | |
tether = pd.read_csv('./../data/tether.csv') |
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
# El mejor día de la semana para vender | |
# Definir una función para calcular los rendimientos semanales | |
def weekly_returns(df): | |
# Ordenar por fecha ascendente | |
df = df.sort_values('date') | |
# Calcular el rendimiento entre cada día de la semana y el último día de la semana | |
weekly_returns = df.groupby(df['date'].dt.weekday)['price'].apply(lambda x: x.iloc[-1]/x.iloc[0]-1) | |
return weekly_returns |
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
# El mejor día de la semana para comprar | |
# Agregar una columna al DataFrame que contenga el nombre del día de la semana correspondiente a cada fecha | |
bitcoin['day'] = bitcoin['date'].dt.day_name() | |
ethereum['day'] = ethereum['date'].dt.day_name() | |
binance['day'] = binance['date'].dt.day_name() | |
# Calcular la media de la columna "Close" para cada día de la semana | |
btc_grouped = bitcoin.groupby('day')['price'].mean() | |
eth_grouped = ethereum.groupby('day')['price'].mean() |
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
# Convertir las fechas a formato de fechas de Pandas | |
bitcoin['date'] = pd.to_datetime(bitcoin['date']) | |
ethereum['date'] = pd.to_datetime(ethereum['date']) | |
binance['date'] = pd.to_datetime(binance['date']) |
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
import pandas as pd | |
import matplotlib.pyplot as plt | |
import seaborn as sns | |
import numpy as np | |
import calendar | |
# Cargar los datos desde el archivo csv | |
bitcoin = pd.read_csv('./../data/bitcoin.csv') | |
ethereum = pd.read_csv('./../data/ethereum.csv') | |
binance = pd.read_csv('./../data/binancecoin.csv') |
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
import pandas as pd | |
import matplotlib.pyplot as plt | |
import seaborn as sns | |
import numpy as np | |
import calendar |