MCPcopy Create free account
hub / github.com/alibaba/GraphScope / to_dataframe

Method to_dataframe

python/graphscope/framework/context.py:161–188  ·  view source on GitHub ↗

Get the context data as a pandas DataFrame. Args: selector: dict The key is column name in dataframe, and the value describes how to select values of context. See more details in derived context DAG node class. vertex_range: dict, opti

(self, selector, vertex_range=None)

Source from the content-addressed store, hash-verified

159 return ResultDAGNode(self, op)
160
161 def to_dataframe(self, selector, vertex_range=None):
162 """Get the context data as a pandas DataFrame.
163
164 Args:
165 selector: dict
166 The key is column name in dataframe, and the value describes how to select
167 values of context. See more details in derived context DAG node class.
168 vertex_range: dict, optional, default to None.
169 Works as slicing. The expression {'begin': m, 'end': n} select a portion
170 of vertices from `m` to, but not including `n`. Type of `m`, `n` must be
171 identical with vertices' oid type.
172 Only the sub-ranges of vertices data will be retrieved.
173 Note the comparison is not based on numeric order, but on alphabetic order.
174
175 Returns:
176 :class:`graphscope.framework.context.ResultDAGNode`:
177 A result holds the `pandas.DataFrame`, evaluated in eager mode.
178 """
179 check_argument(
180 isinstance(selector, Mapping), "selector of to_dataframe must be a dict"
181 )
182 for _, value in selector.items():
183 self._check_selector(value)
184 _ensure_consistent_label(self.context_type, selector)
185 selector = json.dumps(selector)
186 vertex_range = utils.transform_vertex_range(vertex_range)
187 op = dag_utils.context_to_dataframe(self, selector, vertex_range)
188 return ResultDAGNode(self, op)
189
190 def to_vineyard_tensor(self, selector=None, vertex_range=None, axis=0):
191 """Get the context data as a vineyard tensor and return the vineyard object id.

Callers

nothing calls this directly

Calls 5

_check_selectorMethod · 0.95
check_argumentFunction · 0.90
_ensure_consistent_labelFunction · 0.85
ResultDAGNodeClass · 0.85
itemsMethod · 0.80

Tested by

no test coverage detected