import pandas as pd
import datetime as dt
data = pd.read_excel("d:/Documents/Python/Archivosejemplo/AAPL.xlsx")
data = data.sort_values(by="timestamp", ascending=True)
data["variacion"]=data.adjusted_close.pct_change()*100
data.loc[data.index>"2019-01-01"].variacion.plot(kind="hist")
I´m learning from a book, which does the coding scripts in jupyter, and the final graphic line of graphic is the one i write above. When trying to execute that i got the following problem:
TypeError Traceback (most recent call last)
<ipython-input-2-9a9e22482642> in <module>
----> 1 data.loc[data.index>"2019-01-01"].variacion.plot(kind="hist")
~\anaconda3\lib\site-packages\pandas\core\indexes\base.py in cmp_method(self, other)
120 else:
121 with np.errstate(all="ignore"):
--> 122 result = op(self.values, np.asarray(other))
123
124 if is_bool_dtype(result):
TypeError: '>' not supported between instances of 'numpy.ndarray' and 'numpy.ndarray'
If i erase .loc[data.index>"2019-01-01"]
i got a graphic but not the correct one.
Here pictures of the graphics
right graphic (the one i should get)
the one i get with data.variacion.plot(kind="hist")
Thanks a lot and sorry for my bad english. :)
df = pd.DataFrame(...)
- furas