PandasDataSource.update creates datasource with nan
See original GitHub issuesince v 1.5.1
Code that creates nans after ds merge
PandasDataSource.update()
input_df = pd.merge(input_df, df[[]], how='outer', left_index=True, right_index=True)
input_df = input_df.dropna()
seems solves the issue
Steps to reproduce the issue:
- Set a breakpoint to the line described above
- Run example code and press u keypress to update ds
#!/usr/bin/env python3
from datetime import datetime, timedelta
import finplot as fplt
import yfinance as yf
from PyQt5.QtGui import QApplication, QGridLayout
from PyQt5.QtWidgets import QGraphicsView, QLabel
app = QApplication([])
win = QGraphicsView()
win.setWindowTitle('TradingView wannabe')
layout = QGridLayout()
win.setLayout(layout)
win.resize(600, 500)
info = QLabel()
layout.addWidget(info, 0, 1, 1, 1)
ax = fplt.create_plot()
win.axs = [ax] # finplot requres this property
layout.addWidget(ax.vb.win, 1, 0, 1, 2)
barsDate = datetime.fromisoformat("2021-03-12T21:15:55")
offset = timedelta(days=1)
def download(symbol):
global barsDate
items = yf.download(symbol, start=(barsDate).strftime("%Y-%m-%d"), end=(barsDate + offset).strftime("%Y-%m-%d"), interval='15m')
print((barsDate + offset).strftime("%Y-%m-%d") + " - " + barsDate.strftime("%Y-%m-%d"))
barsDate -= offset
return items
plots = []
def update():
df = download("AMD")
if len(df) < 20: # symbol does not exist
return
price = df['Open Close High Low'.split()]
if not plots:
plots.append(fplt.candlestick_ochl(price))
else:
plots[0].update_data(price)
def _key_pressed(vb, ev):
if ev.text() == 'u':
update()
fplt._key_pressed = _key_pressed
update()
fplt.show(qt_exec=False) # prepares plots when they're all setup
win.show()
app.exec_()
Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (5 by maintainers)
Top Results From Across the Web
pandas: best practice to create multiple distinguishable ...
I have numeric timeseries data in a DataFrame, where individual columns are periodically updated from a live data source.
Read more >How to modify values in a Pandas DataFrame?
Updating values in specific cells by index; Changing values in an entire DF row; Replace cells content according to condition; Modify values in...
Read more >Simplify your Dataset Cleaning with Pandas | by Ulysse Petit
Extract relevant content from a Series; Check NaN values; Change the type of your Series. Open a new Jupyter notebook and import the...
Read more >Working with missing data — pandas 1.5.2 documentation
In this section, we will discuss missing (also referred to as NA) values in pandas. Note. The choice of using NaN internally to...
Read more >[BUG] vbar_stack with DataFrame as source ignores entire ...
When plotting a vbar_stack , the entire row in the data source is ignored if the first input column contains a NaN in...
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
Many people ask for similar stuff, so added a reset functionality in 4a30ba28abd37a22155fef646f9003979ef61129. Use like so:
No need to store plots for later, just reset and plot again. GL!
I’ve included this functionality in an example.