morpheus.messages.message_meta.UserMessageMeta
- class UserMessageMeta(df, user_id)[source]
Bases:
morpheus.messages.message_meta.MessageMeta
This class extends MessageMeta to also hold userid corresponding to batched metadata.
- Parameters
- df
- user_id
Input rows in dataframe.
User id.
- Attributes
count
- df
Returns the number of messages in the batch.
Methods
copy_ranges
(ranges)Perform a copy of the current message instance for the given ranges
of rows.ensure_sliceable_index
()Replaces the index in the underlying dataframe if the existing one is not unique and monotonic. get_data
([columns])Return column values from the underlying DataFrame. get_meta_range
(mess_offset, message_count[, ...])Return column values from morpheus.pipeline.messages.MessageMeta.df
from the specified start offset until the message count.get_slice
(start, stop)Returns a new MessageMeta with only the rows specified by start/stop. has_sliceable_index
()Returns True if the underlying DataFrame's index is unique and monotonic. set_data
(columns, value)Set column values to the underlying DataFrame. copy_dataframe get_column_names mutable_dataframe - copy_ranges(ranges)[source]
Perform a copy of the current message instance for the given
ranges
of rows.- Parameters
- ranges
Rows to include in the copy in the form of
[(`start_row
,stop_row
),…]` Thestop_row
isn’t included. For example to copy rows 1-2 & 5-7ranges=[(1, 3), (5, 8)]
- Returns
MessageMeta
A new
MessageMeta
with only the rows specified byranges
.
- property count: int
Returns the number of messages in the batch.
- Returns
- int
number of messages in the MessageMeta.df.
- ensure_sliceable_index()[source]
Replaces the index in the underlying dataframe if the existing one is not unique and monotonic. The old index will be preserved in a column named
_index_{old_index.name}
. Ifhas_sliceable_index() == true
, this is a no-op.- Returns
- str
The name of the column with the old index or
None
if no changes were made
- get_data(columns=None)[source]
Return column values from the underlying DataFrame.
- Parameters
- columns
Input column names. Returns all columns if
None
is specified. When a string is passed, aSeries
is returned. Otherwise, aDataframe
is returned.- Returns
- Series or Dataframe
Column values from the dataframe.
- get_meta_range(mess_offset, message_count, columns=None)[source]
Return column values from
morpheus.pipeline.messages.MessageMeta.df
from the specified start offset until the message count.- Parameters
- mess_offset
- message_count
- columns
Offset into the metadata batch.
Messages count.
Input column names. Returns all columns if
None
is specified. When a string is passed, aSeries
is returned. Otherwise aDataframe
is returned.- Returns
- Series or Dataframe
Column values from the dataframe.
- get_slice(start, stop)[source]
Returns a new MessageMeta with only the rows specified by start/stop.
- Parameters
- start
- stop
Start offset address.
Stop offset address.
- Returns
MessageMeta
A new
MessageMeta
with sliced offset and count.
- has_sliceable_index()[source]
Returns True if the underlying DataFrame’s index is unique and monotonic. Sliceable indices have better performance since a range of rows can be specified by a start and stop index instead of requiring boolean masks.
- Returns
- bool
- set_data(columns, value)[source]
Set column values to the underlying DataFrame.
- Parameters
- columns
- value
Input column names. Sets the value for the corresponding column names. If
None
is specified, all columns will be used. If the column does not exist, a new one will be created.Value to apply to the specified columns. If a single value is passed, it will be broadcast to all rows. If a
Series
orDataframe
is passed, rows will be matched by index.