Real tail of stream (last n elements)
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 32/100
- issue の種類
- 機能追加
- 明瞭さ
- おおむね明確
- 活発さ
- 停滞
- 技術スタック
- pandas, python
調査の方向性
Start with the Stream.from_periodic example and trace the accumulate(...).to_dataframe path used to retain DataFrame batches. The issue names no source file or test, so first determine where stream accumulation and window behavior are implemented. Done means agreeing on the API and semantics for exposing the last n elements, then verifying that behavior for the shown DataFrame workflow.
索引モデルが issue の本文から書いたものです。
説明
To my knowledge there is currently no way to show (or plot) the last n elements of a Streamz DataFrame.
I think this is a very useful function for debugging, but also for slower Streamz, for example CFD results from OpenFOAM.
Here is a naive implementation:
def tail(length):
def tail_func(x, y):
x = x.append(y, ignore_index=True)
return x.iloc[-length:].reset_index(drop=True)
return tail_func
Here is an example:
(thanks for the feedback @martindurant)
import pandas as pd
from streamz import Stream
import numpy as np
names = ["Mike", "Tim", "Anna", "Kim", "Andy"]
def emitter():
n = np.random.randint(1, 5)
return {"name": np.random.choice(names, n), "age": np.random.randint(18, 32, n)}
stream = Stream.from_periodic(emitter, 1)
df1 = pd.DataFrame({"name": ["test"], "age": [40]})
out = stream.map(pd.DataFrame).accumulate(tail(6), start=pd.DataFrame()).to_dataframe(df1)
# out.stream.sink(print) # optional, or some other output
stream.start()
# if using a Jupyter Lab
out
This could either be the bare representation of window or could replace the tail function. I think the name tail suits this function better than the current one. What do you think?
Implementation wise one could be much more efficient by using .loc and round robin replacing values and saving the order somewhere else, but for a first go, I would stick by the naive version.
- 主要言語
- Python
- スター
- 1.3k
- フォーク
- 149
- PR マージ指標
- 30日以内にマージされた PR はありません
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
python-streamz/streamz のほかの issue
-
難易度 3/5 1〜2日 初心者へのやさしさ 35/100
python-streamz/streamz#481 · コメント 4 件 ·
-
Combining the streamz.Stream.filenames() and streamz.Stream.from_textfile() using dask scatter? オープン
難易度 5/5 1週間以上 初心者へのやさしさ 25/100
python-streamz/streamz#480 · コメント 2 件 ·
-
難易度 5/5 1週間以上 初心者へのやさしさ 20/100
python-streamz/streamz#479 · コメント 1 件 ·
-
難易度 5/5 1週間以上 初心者へのやさしさ 20/100
python-streamz/streamz#478 · コメント 6 件 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 10/100
python-streamz/streamz#476 · コメント 17 件 · リアクション 2 件 ·
python-streamz/streamz の issue をすべて見る
似ている issue
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
use-agent-os/agent-os#3314 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
BasedHardware/omi#15662 · コメント 1 件 ·
-
documentation help wanted
難易度 2/5 1〜3時間 初心者へのやさしさ 90/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
AiursoftWeb/AnduinOS-2#19 ·