Skip to content

Commit

Permalink
added a little more documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
tim-quix committed Jul 16, 2024
1 parent 2efa326 commit 1bf9c8b
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions quixstreams/dataframe/dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,13 +283,17 @@ def update(
The result of the function will be ignored, and the original value will be
passed downstream.
Reassignment is OPTIONAL for this operation (is applied regardless).
Example Snippet:
```python
# Stores a value and mutates a list by appending a new item to it.
# Also prints to console.
logger = logging.get_logger()
def func(values: list, state: State):
value = values[0]
if value != state.get("my_store_key"):
Expand All @@ -298,7 +302,8 @@ def func(values: list, state: State):
sdf = StreamingDataframe()
sdf = sdf.update(func, stateful=True)
sdf = sdf.update(lambda value: print("Received value: ", value))
# does not require reassigning
sdf.update(lambda v: logger.info("message value is {v}"))
```
:param func: function to update value
Expand Down Expand Up @@ -546,6 +551,8 @@ def to_topic(
"""
Produce current value to a topic. You can optionally specify a new key.
Reassignment is OPTIONAL for this operation (is applied regardless).
Example Snippet:
```python
Expand All @@ -560,7 +567,8 @@ def to_topic(
sdf = app.dataframe(input_topic)
sdf = sdf.to_topic(output_topic_0)
sdf = sdf.to_topic(output_topic_1, key=lambda data: data["a_field"])
# does not require reassigning
sdf.to_topic(output_topic_1, key=lambda data: data["a_field"])
```
:param topic: instance of `Topic`
Expand Down Expand Up @@ -680,7 +688,7 @@ def print(self, pretty: bool = False, metadata: bool = False) -> Self:
Can also output a more dict-friendly format with `pretty=True`.
Reassignment is OPTIONAL for this function (is applied regardless).
Reassignment is OPTIONAL for this operation (is applied regardless).
> NOTE: prints the current (edited) values, not the original values.
Expand Down

0 comments on commit 1bf9c8b

Please sign in to comment.