Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dft.geckoHistorical('bitcoin') #8

Open
gumartinez opened this issue Oct 20, 2021 · 3 comments
Open

dft.geckoHistorical('bitcoin') #8

gumartinez opened this issue Oct 20, 2021 · 3 comments

Comments

@gumartinez
Copy link

Buenas, intento correr el codigo en Spyder:

dft.geckoHistorical('bitcoin')

y me da el error

dft.geckoHistorical('bitcoin')
Traceback (most recent call last):

File "", line 1, in
dft.geckoHistorical('bitcoin')

File "C:\Users\gmartinez\Anaconda3\lib\site-packages\defi\defi_tools.py", line 227, in geckoHistorical
df[0] = pd.to_datetime(df[0], unit='ms')

File "C:\Users\gmartinez\Anaconda3\lib\site-packages\pandas\core\frame.py", line 2938, in setitem
self._set_item(key, value)

File "C:\Users\gmartinez\Anaconda3\lib\site-packages\pandas\core\frame.py", line 3001, in _set_item
NDFrame._set_item(self, key, value)

File "C:\Users\gmartinez\Anaconda3\lib\site-packages\pandas\core\generic.py", line 3624, in _set_item
self._data.set(key, value)

File "C:\Users\gmartinez\Anaconda3\lib\site-packages\pandas\core\internals\managers.py", line 1086, in set
for blkno, val_locs in libinternals.get_blkno_placements(blknos, group=True):

File "pandas_libs\internals.pyx", line 448, in get_blkno_placements

File "pandas_libs\internals.pyx", line 352, in pandas._libs.internals.get_blkno_indexers

ValueError: Buffer has wrong number of dimensions (expected 1, got 0)

Cuando lo hago en colab no me sucede esto.

@gauss314
Copy link
Owner

gauss314 commented Nov 3, 2021

Es alguna actualizacion de pandas de tu anaconda local, por eso no tenes el error en colab, te sugiero abrir el anaconda prompt y ejecutar esto:

conda update --all

va a tardar 15 minutos pero luego de eso deberia andar bien

@gumartinez
Copy link
Author

Actualice conda y cuando corro

import yfinance as yf
import seaborn as sns
import numpy as np
import calendar
import matplotlib.pyplot as plt
from matplotlib.gridspec import GridSpec
from matplotlib.colors import LinearSegmentedColormap
import pandas as pd
import seaborn as sns
pd.options.plotting.backend = "plotly"

cmap_jp = LinearSegmentedColormap.from_list('Custom', ('red','black','green'), N=256)

df = yf.download('GDX', auto_adjust=True, progress=False)
df = df.loc[df.index.year > 1980].copy()
df["Year"] = df.index.year
df["Month"] = df.index.month
df = df.resample('M').last()
df['variacion'] = df.Close.pct_change()
tabla = df.pivot_table(index="Year",columns="Month",values="variacion")
meses = [x[:3] for x in list(calendar.month_name[1:])]
tabla.columns = meses

plt.style.use('dark_background')
#plt.style.use('classic') """ https://matplotlib.org/stable/gallery/style_sheets/style_sheets_reference.html"""
fig = plt.figure(figsize=(20,12))
gs = GridSpec(nrows=3,ncols=2, figure=fig, width_ratios=[2.5,1], hspace=0.2, wspace=0.1, top=.9)
ax_l = fig.add_subplot(gs[:,0])
ax_r = [fig.add_subplot(gs[i,1]) for i in range(3)]

sc = lambda y: (y - y.min()) / (y.max() - y.min())
ax_r[0].bar(meses, tabla.mean(), color=cmap_jp(sc(tabla.mean())), label='Media', width=.7, edgecolor='gray')
ax_r[1].bar(meses, tabla.median(), color=cmap_jp(sc(tabla.median())), label = 'Mediana', width=.7, edgecolor='gray')
ax_r[2].bar(meses, tabla.kurt(), color=cmap_jp(sc(tabla.kurt())), label = 'Kurtosis', width=.7, edgecolor='gray')
[ax_r[i].legend(fontsize=12) for i in range(3)]
[ax_r[i].grid(alpha=.5) for i in range(3)]

sns.heatmap(tabla, annot=True, ax=ax_l, cmap=cmap_jp, fmt='.2%', vmax=0.15, vmin=-0.15, cbar_kws={"shrink": 0.6})
ax_l.set_title('SP500 Rendimientos Mensuales 1981-2021', fontsize=15)
print('\n')
plt.show()
print('\n')

El kernel se muere y no ejecuta, sin embargo otros codigos los corre sin problema

@gauss314
Copy link
Owner

gauss314 commented Nov 6, 2021

Anda borrando lineas de abajo hacia arriba a ver cual es la conflictiva, es raro a mi me corre lo mas bien, seguro es alguna libreria en tu instalacion que te esta generando un conflicto

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants