(df.index)): TypeError: '>' not supported between instances of 'str' and 'float'
See original GitHub issueHi Jonas, Thanks for this wonderful gem of a library 😃 HERE is a comment from you a while back. Now I’m trying to plot data from a json object.
THIS Is the API endpoint.
When I try below code based on your advice (I’m nearly certain I’m doing it wrong),
import requests as rq
import pandas as pd
import finplot as fplt
url = 'https://www.alphavantage.co/query?function=TIME_SERIES_INTRADAY&symbol=IBM&interval=5min&apikey=demo'
r = rq.get(url).json()
ax = fplt.create_plot('test', rows=1)
# plot candle sticks
fplt.candlestick_ochl(r['Time Series (5min)'], ax=ax)
I’m met with this traceback,
Traceback (most recent call last):
File "C:\BeingProfessional\projects\Py\SoFlow.py", line 22, in <module>
fplt.candlestick_ochl(r['Time Series (5min)'], ax=ax)
File "C:\Program Files\Python37-32\lib\site-packages\finplot\__init__.py", line 1254, in candlestick_ochl
datasrc = _create_datasrc(ax, datasrc)
File "C:\Program Files\Python37-32\lib\site-packages\finplot\__init__.py", line 1819, in _create_datasrc
datasrc = do_create(*args)
File "C:\Program Files\Python37-32\lib\site-packages\finplot\__init__.py", line 1818, in do_create
return PandasDataSource(pd.concat(args, axis=1))
File "C:\Program Files\Python37-32\lib\site-packages\finplot\__init__.py", line 160, in __init__
if type(df.index) == pd.DatetimeIndex or df.index[-1]>1e7 or '.RangeIndex' not in str(type(df.index)):
TypeError: '>' not supported between instances of 'str' and 'float'
My queries are,
- How do I plot this json response data in finplot? If it makes it easier, I am okay with a solution with pandas.
- Why does finplot throw this error?
- If there is something wrong with this json formatting, how about the TD Ameritrade API’s price history json? I know how to use TDA API, but how do I plot that data in finplot? The json schema looks like THIS
I’ll appreciate any help or suggestion…
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
TypeError: '>' not supported between instances of 'float' and ...
This is due to the series df[cat] containing elements that have varying data types e.g.(strings and/or floats). This could be due to the...
Read more >Getting "TypeError: '>' not supported between instances of 'str ...
It is due to the missing values in the columns gender,married and dependents. use df.count() to check which columns have missing values and...
Read more >' not supported between instances of 'str' and 'int' - Java2Blog
In this article you will learn about the causes and solutions of - TypeError: '<' not supported between instances of 'str' and 'int'...
Read more >BUG: TypeError: '<' not supported between instances of 'float ...
I use df. combine_first(...) to add a column to a dataframe while extending the index in case an index value does not exist...
Read more >Solve typeerror not supported between instances of str and int ...
As mentioned above, the root cause is that the variable instances of string and integer type are not compatible and hence can't be...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Btw. this is what you need to do to get your first example plotting:
Note though, that the open and close columns are actually inversed in the downloaded data! We fix by simply flipping open and close when plotting like so:
… regarding your first example/bug you need some more data processing, but out of the scope for a plotting library:
Then you can plot.