EXPAND ALL
  • Home

DataFrame.ctx.__getitem__

Creates the specified metadata as a column.

Shorthand for exposing metadata columns in the DataFrame. Each metadata type can be converted from some sets of other metadata types that already exist in the DataFrame. Attempting to convert to a metadata type that doesn't have the source column will raise a compiler error. Available keys (and any aliases) as well as the source columns.

  • container_id (): Sources: "upid"
  • service_id: Sources: "upid","service_name"
  • service_name ("service"): Sources: "upid","service_id"
  • pod_id: Sources: "upid","pod_name"
  • pod_name ("pod"): Sources: "upid","pod_id"
  • deployment_id: Sources: "deployment_name","pod_id","pod_name","replicaset_name", "replicaset_id"
  • deployment_name ("deployment"): Sources: "upid","deployment_id","pod_id","pod_name","replicaset_name", "replicaset_id"
  • replicaset_id ("replica_set_id"): Sources: "upid","pod_id","pod_name", "replicaset_name"
  • replicaset_name ("replica_set", "replicaset"): Sources: "upid","pod_id","pod_name", "replicaset_id"
  • namespace: Sources: "upid"
  • node_name ("node"): Sources: "upid"
  • hostname ("host"): Sources: "upid"
  • container_name ("container"): Sources: "upid"
  • cmdline ("cmd"): Sources: "upid"
  • asid: Sources: "upid"
  • pid: Sources: "upid"

Arguments

NameTypeDescription
metadatastringThe metadata property you wish to access. Function will throw an error if it doesn't exist.

Returns

px.Column: Column that represents the metadata in the DataFrame. Can be used in a DataFrame expression.

Examples

df = px.DataFrame('http_events', start_time='-5m')
# Filter only for data that matches the metadata service.
# df.ctx['service'] pulls the service column into the DataFrame.
df = df[df.ctx['service'] == "pl/vizier-metadata"]
df = px.DataFrame('http_events', start_time='-5m')
# Add the service column from the metadata object.
df.service = df.ctx['service']
# Group by the service.
df = df.groupby('service').agg(req_count=('service', px.count))
# Where metadata context can fail.
df = px.DataFrame('http_events', start_time='-5m')
# Dropping upid so we remove the "source" column we could use
df = df.drop('upid')
# FAILS: no source column available for the metadata conversion.
df.service = df.ctx['service']

This site uses cookies to provide you with a better user experience. By using Pixie, you consent to our use of cookies.