9. Using Frames¶
The PgxFrame class can be used to perform operations on a given frame.
- class pypgx.api.PgxFrame(java_pgx_frame)
- clone()
Create a new PgxFrame with the same content as the current frame
- Returns
PgxFrame
- close()
Free resources on the server taken up by this frame.
- count()
Count number of elements in the frame.
- destroy()
Free resources on the server taken up by this frame.
- flatten(*columns, inplace=False)
Create a new PgxFrame with all the specified columns and vector columns flattened into multiple columns.
- Parameters
columns – Column names
inplace – Apply the changes inplace and return self
- Returns
PgxFrame
- flatten_all(inplace=False)
Create a new PgxFrame with all nested columns and vector columns flattened into multiple columns.
- Parameters
inplace – Apply the changes inplace and return self
- Returns
PgxFrame
- get_column(name)
Return a PgxFrameColumn.
- Parameters
name – Column name
- Returns
PgxFrameColumn
- get_column_descriptors()
Return a list containing the description of the different columns of the frames.
- head(num_rows=10, inplace=False)
Return the first num_rows elements of the frame
- Parameters
num_rows – Number of rows to take
inplace – Apply the changes inplace and return self
- Returns
PgxFrame
- join(right, join_key_column=None, left_join_key_column=None, right_join_key_column=None, left_prefix=None, right_prefix=None, inplace=False)
- Create a new PgxFrame by adding the columns of the right frame to this frame, aligned on
equality of entries in column left_join_key_column for this frame and column right_join_key_column for the right frame, or join_key_columns on both frames. The resulting frame will contain the columns of this frame prefixed by left_prefix and the columns of right frame prefixed by right_prefix (if the prefixes are not null). Prefixes must ether not be set or both be set.
- Parameters
right – PgxFrame whose columns will be added to the columns of this PgxFrame
join_key_column – Column of both frames on which the equality test will be performed
left_join_key_column – Column of this frame on which the equality test will be
performed with right_join_key_column :param right_join_key_column: Column of right frame on which the equality test will be performed with leftJoinKeyColumn :param left_prefix: Prefix of the columns name of this frame in the resulting frame :param right_prefix: Prefix of the columns name of right frame in the resulting frame :param inplace: Apply the changes inplace and return self :returns: PgxFrame
- property length
Return the number of rows in the frame.
- Returns
number of rows
- print(file=None, num_results=1000, start=0)
Print the frame.
- Parameters
file – File to which results are printed (default is
sys.stdout
)num_results – Number of results to be printed
start – Index of the first result to be printed
- rename_column(old_column_name, new_column_name, inplace=False)
Return a PgxFrame with the column name modified.
- Parameters
old_column_name – name of the column to rename
new_column_name – name of the column after the operation
inplace – Apply the changes inplace and return self
- Returns
PgxFrame
- rename_columns(column_renaming, inplace=False)
Return a PgxFrame with the column name modified.
- Parameters
column_renaming – dict-like holding old_column names as keys and new column names as
values :param inplace: Apply the changes inplace and return self :returns: PgxFrame
- select(*columns, inplace=False)
Select multiple columns by column name.
- Parameters
columns – Column names
inplace – Apply the changes inplace and return self
- Returns
PgxFrame
- store(path, file_format='csv', overwrite=True)
Store the frame in a file.
- Parameters
path – Path where to store the frame
file_format – Storage format
overwrite – Overwrite current file
- tail(num_rows=10, inplace=False)
Return the last num_rows elements of the frame
- Parameters
num_rows – Number of rows to take
inplace – Apply the changes inplace and return self
- Returns
PgxFrame
- to_pandas()
Convert to pandas DataFrame.
This method may change result_set cursor.
This method requires pandas.
- Returns
PgxFrame as a Pandas Dataframe
- to_pgql_result_set()
Create a new PgqlResultSet having the same content as this frame.
- Returns
PgqlResultSet
- union(*frames, inplace=False)
Create a PgxFrame by concatenating the rows of this frame with the rows of the frames in frames. The different frames should have the same columns (same names, types and dimensions), in the same order. The resulting frame is not guaranteed to have any specific ordering of its rows.
- Parameters
frames – Frames tu add through union
inplace – Apply the changes inplace and return self
- Returns
PgxFrame
- write()
Get Pgx Frame storer
- Returns
PgxGenericFrameStorer