Skip to content

Instantly share code, notes, and snippets.

@merlin-quix
Created February 24, 2023 09:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save merlin-quix/406da5e06fd0b19bea1bff8396135796 to your computer and use it in GitHub Desktop.
Save merlin-quix/406da5e06fd0b19bea1bff8396135796 to your computer and use it in GitHub Desktop.
OSS announcement
# Create a projection for columns we need.
df = input_stream.df[["gForceX", "gForceY", "gForceZ"]]
# Create new feature by simply combining three columns to one new column.
df["gForceTotal"] = df["gForceX"].abs() + df["gForceY"].abs() + df["gForceZ"].abs()
# Calculate rolling window of previous column for last 10 minutes
df["gForceTotal_avg10s"] = df["gForceTotal"].rolling("10m").mean()
# Loop through the stream row by row as data frow through the service.
# Async iterator will stop the code if there is no new data incoming from i
async for row in df:
print(row)
await output_stream.write(row)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment