Detail: Frame: Exporter
- Frame.to_arrow(*, include_index=True, include_index_name=True, include_columns=True, include_columns_name=False)[source]
Return a
pyarrow.Table
from thisFrame
.>>> f = sf.Frame.from_fields(((10, 2, 8, 3), ('qrs ', 'XYZ', '123', ' wX ')), columns=('a', 'b'), index=('p', 'q', 'r', 's'), name='x') >>> f <Frame: x> <Index> a b <<U1> <Index> p 10 qrs q 2 XYZ r 8 123 s 3 wX <<U1> <int64> <<U4> >>> f.to_arrow() pyarrow.Table __index0__: string a: int64 b: string ---- __index0__: [["p","q","r","s"]] a: [[10,2,8,3]] b: [["qrs ","XYZ","123"," wX "]]
- Frame.to_clipboard(*, delimiter='\t', include_index=True, include_index_name=True, include_columns=True, include_columns_name=False, encoding=None, line_terminator='\n', quote_char='"', quote_double=True, escape_char=None, quoting=0, store_filter=<static_frame.core.store_filter.StoreFilter object>)[source]
Given a file path or file-like object, write the
Frame
as delimited text. Thedelimiter
defaults to a tab.- Parameters:
path (A file) –
instance (PathLib) –
object. (or file-like) –
* –
delimiter – Character to be used for delimiterarating elements.
include_index – If True, the index will be written.
include_index_name – If including columns, populate the row above the index with the index
name
. Cannot be True ifinclude_columns_name
isTrue
.include_columns – If
True
, the columns will be written.include_columns_name – If including index, populate the column to the left of the columns with the columns
name
. Cannot be True ifinclude_index_name
is True.encoding – Encoding type to be used when opening the file.
line_terminator – The string used to terminate lines.
quote_char – A one-character string used to quote fields containing special characters, such as the
delimiter
orquote_char
, or which contain new-line characters.quote_double – Controls how instances of quote_char appearing inside a field should themselves be quoted. When
True
, the character is doubled. WhenFalse
, theescape_char
is used as a prefix to thequote_char
. It defaults to True.escape_char – A one-character string used by the writer to escape the delimiter if quoting is set to QUOTE_NONE and the quotechar if quote_double is False.
quoting – Controls when quotes should be generated. It can take on any of the QUOTE_* constants from the standard library csv module.
store_filter – A
StoreFilter
instance.
>>> f1 = sf.Frame(np.arange(6).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='x') >>> f1.to_clipboard()
- Frame.to_csv(fp, *, include_index=True, include_index_name=True, include_columns=True, include_columns_name=False, encoding=None, line_terminator='\n', quoting=0, quote_char='"', quote_double=True, escape_char=None, store_filter=<static_frame.core.store_filter.StoreFilter object>)[source]
Given a file path or file-like object, write the
Frame
as delimited text. The delimiter is set to a comma.- Parameters:
path (A file) –
instance (PathLib) –
object. (or file-like) –
* –
include_index – If True, the index will be written.
include_index_name – If including columns, populate the row above the index with the index
name
. Cannot be True ifinclude_columns_name
isTrue
.include_columns – If
True
, the columns will be written.include_columns_name – If including index, populate the column to the left of the columns with the columns
name
. Cannot be True ifinclude_index_name
is True.encoding – Encoding type to be used when opening the file.
line_terminator – The string used to terminate lines.
quote_char – A one-character string used to quote fields containing special characters, such as the
delimiter
orquote_char
, or which contain new-line characters.quote_double – Controls how instances of quote_char appearing inside a field should themselves be quoted. When
True
, the character is doubled. WhenFalse
, theescape_char
is used as a prefix to thequote_char
. It defaults to True.escape_char – A one-character string used by the writer to escape the delimiter if quoting is set to QUOTE_NONE and the quotechar if quote_double is False.
quoting – Controls when quotes should be generated. It can take on any of the QUOTE_* constants from the standard library csv module.
store_filter – A
StoreFilter
instance.
>>> f1 = sf.Frame(np.arange(6).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='x') >>> f1 <Frame: x> <Index> a b <<U1> <Index> p 0 1 q 2 3 r 4 5 <<U1> <int64> <int64> >>> f1.to_csv('/tmp/f.csv') >>> from pathlib import Path >>> Path('/tmp/f.csv').read_text() __index0__,a,b p,0,1 q,2,3 r,4,5
- Frame.to_delimited(fp, *, delimiter, include_index=True, include_index_name=True, include_columns=True, include_columns_name=False, encoding=None, line_terminator='\n', quote_char='"', quote_double=True, escape_char=None, quoting=0, store_filter=<static_frame.core.store_filter.StoreFilter object>)[source]
Given a file path or file-like object, write the
Frame
as delimited text. Adelimiter
character must be specified.- Parameters:
path (A file) –
instance (PathLib) –
object. (or file-like) –
* –
delimiter – Character to be used for delimiterarating elements.
include_index – If True, the index will be written.
include_index_name – If including columns, populate the row above the index with the index
name
. Cannot be True ifinclude_columns_name
isTrue
.include_columns – If
True
, the columns will be written.include_columns_name – If including index, populate the column to the left of the columns with the columns
name
. Cannot be True ifinclude_index_name
is True.encoding – Encoding type to be used when opening the file.
line_terminator – The string used to terminate lines.
quote_char – A one-character string used to quote fields containing special characters, such as the
delimiter
orquote_char
, or which contain new-line characters.quote_double – Controls how instances of quote_char appearing inside a field should themselves be quoted. When
True
, the character is doubled. WhenFalse
, theescape_char
is used as a prefix to thequote_char
. It defaults to True.escape_char – A one-character string used by the writer to escape the delimiter if quoting is set to QUOTE_NONE and the quotechar if quote_double is False.
quoting – Controls when quotes should be generated. It can take on any of the QUOTE_* constants from the standard library csv module.
store_filter – A
StoreFilter
instance.
>>> f1 = sf.Frame(np.arange(6).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='x') >>> f1 <Frame: x> <Index> a b <<U1> <Index> p 0 1 q 2 3 r 4 5 <<U1> <int64> <int64> >>> f1.to_delimited('/tmp/f.psv', delimiter='|') >>> from pathlib import Path >>> Path('/tmp/f.psv').read_text() __index0__|a|b p|0|1 q|2|3 r|4|5
- Frame.to_duckdb(fp, *, label=<object object>, include_index=True, include_columns=True)[source]
Write the Frame as single-table DuckDB file.
>>> f1 = sf.Frame.from_fields(((10, 2, 8, 3), ('qrs ', 'XYZ', '123', ' wX ')), columns=('a', 'b'), index=('p', 'q', 'r', 's'), name='x') >>> f1 <Frame: x> <Index> a b <<U1> <Index> p 10 qrs q 2 XYZ r 8 123 s 3 wX <<U1> <int64> <<U4> >>> f1.to_duckdb('/tmp/f.db') >>> import duckdb >>> conn = duckdb.connect('/tmp/f.db') >>> sf.Frame.from_sql("select * from x limit 2", connection=conn, index_depth=1) TypeError("'duckdb.duckdb.DuckDBPyConnection' object is not iterable")
- Frame.to_frame(*, name=<object object>)[source]
Return
Frame
instance from thisFrame
. If thisFrame
is immutable the same instance will be returned.>>> f = sf.Frame.from_fields(((10, 2, 8, 3), ('qrs ', 'XYZ', '123', ' wX ')), columns=('a', 'b'), index=('p', 'q', 'r', 's'), name='x') >>> f <Frame: x> <Index> a b <<U1> <Index> p 10 qrs q 2 XYZ r 8 123 s 3 wX <<U1> <int64> <<U4> >>> f.to_frame() <Frame: x> <Index> a b <<U1> <Index> p 10 qrs q 2 XYZ r 8 123 s 3 wX <<U1> <int64> <<U4>
- Frame.to_frame_go(*, name=<object object>)[source]
Return a
FrameGO
instance from thisFrame
.>>> f = sf.Frame.from_fields(((10, 2, 8, 3), ('qrs ', 'XYZ', '123', ' wX ')), columns=('a', 'b'), index=('p', 'q', 'r', 's'), name='x') >>> f <Frame: x> <Index> a b <<U1> <Index> p 10 qrs q 2 XYZ r 8 123 s 3 wX <<U1> <int64> <<U4> >>> f.to_frame_go() <FrameGO: x> <IndexGO> a b <<U1> <Index> p 10 qrs q 2 XYZ r 8 123 s 3 wX <<U1> <int64> <<U4>
- Frame.to_frame_he(*, name=<object object>)[source]
Return a
FrameHE
instance from thisFrame
. If thisFrame
is immutable the same instance will be returned.>>> f = sf.Frame.from_fields(((10, 2, 8, 3), ('qrs ', 'XYZ', '123', ' wX ')), columns=('a', 'b'), index=('p', 'q', 'r', 's'), name='x') >>> f <Frame: x> <Index> a b <<U1> <Index> p 10 qrs q 2 XYZ r 8 123 s 3 wX <<U1> <int64> <<U4> >>> f.to_frame_he() <FrameHE: x> <Index> a b <<U1> <Index> p 10 qrs q 2 XYZ r 8 123 s 3 wX <<U1> <int64> <<U4>
- Frame.to_hdf5(fp, *, label=<object object>, include_index=True, include_columns=True)[source]
Write the Frame as single-table SQLite file.
>>> f1 = sf.Frame(np.arange(6).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='x') >>> f1 <Frame: x> <Index> a b <<U1> <Index> p 0 1 q 2 3 r 4 5 <<U1> <int64> <int64> >>> f1.to_hdf5('/tmp/f.h5')
- Frame.to_html(config=None, style_config=<static_frame.core.style_config.StyleConfig object>)[source]
Return an HTML table representation of this
Frame
using standard TABLE, TR, and TD tags. This is not a complete HTML page.- Parameters:
config – Optional
DisplayConfig
instance.- Returns:
str
- Frame.to_html_datatables(fp=None, show=True, config=None)[source]
Return a complete HTML representation of this
Frame
using the DataTables JS library for table naviagation and search. The page links to CDNs for JS resources, and thus will not fully render without an internet connection.- Parameters:
fp – optional file path to write; if not provided, a temporary file will be created. Note: the caller is responsible for deleting this file.
show – if True, the file will be opened with a webbrowser.
config – Optional
DisplayConfig
instance.
- Returns:
str
, absolute file path to the file written.
- Frame.to_json_columns(indent=None)[source]
Export a
Frame
as a JSON string constructed as follows: A JSON object keyed by column labels, where values are columns represented by an object mapping of index labels to values.- Parameters:
indent – If indent is a non-negative integer or string, then JSON array elements and object members will be pretty-printed with that indent level.
>>> f = sf.Frame.from_fields(((10, 2, 8, 3), (False, True, True, False), ('1517-01-01', '1517-04-01', '1517-12-31', '1517-06-30')), columns=('a', 'b', 'c'), dtypes=dict(c=np.datetime64), name='x') >>> f <Frame: x> <Index> a b c <<U1> <Index> 0 10 False 1517-01-01 1 2 True 1517-04-01 2 8 True 1517-12-31 3 3 False 1517-06-30 <int64> <int64> <bool> <datetime64[D]> >>> f.to_json_columns(indent=4) { "a": { "0": 10, "1": 2, "2": 8, "3": 3 }, "b": { "0": false, "1": true, "2": true, "3": false }, "c": { "0": "1517-01-01", "1": "1517-04-01", "2": "1517-12-31", "3": "1517-06-30" } }
- Frame.to_json_index(indent=None)[source]
Export a
Frame
as a JSON string constructed as follows: A JSON object keyed by index labels, where values are rows represented by an object mapping of column labels to values.- Parameters:
indent – If indent is a non-negative integer or string, then JSON array elements and object members will be pretty-printed with that indent level.
>>> f = sf.Frame.from_fields(((10, 2, 8, 3), (False, True, True, False), ('1517-01-01', '1517-04-01', '1517-12-31', '1517-06-30')), columns=('a', 'b', 'c'), dtypes=dict(c=np.datetime64), name='x') >>> f <Frame: x> <Index> a b c <<U1> <Index> 0 10 False 1517-01-01 1 2 True 1517-04-01 2 8 True 1517-12-31 3 3 False 1517-06-30 <int64> <int64> <bool> <datetime64[D]> >>> f.to_json_index(indent=4) { "0": { "a": 10, "b": false, "c": "1517-01-01" }, "1": { "a": 2, "b": true, "c": "1517-04-01" }, "2": { "a": 8, "b": true, "c": "1517-12-31" }, "3": { "a": 3, "b": false, "c": "1517-06-30" } }
- Frame.to_json_records(indent=None)[source]
Export a
Frame
as a JSON string constructed as follows: A JSON array of row objects, where column labels are repeated for each row, and no index labels are included.- Parameters:
indent – If indent is a non-negative integer or string, then JSON array elements and object members will be pretty-printed with that indent level.
>>> f = sf.Frame.from_fields(((10, 2, 8, 3), (False, True, True, False), ('1517-01-01', '1517-04-01', '1517-12-31', '1517-06-30')), columns=('a', 'b', 'c'), dtypes=dict(c=np.datetime64), name='x') >>> f <Frame: x> <Index> a b c <<U1> <Index> 0 10 False 1517-01-01 1 2 True 1517-04-01 2 8 True 1517-12-31 3 3 False 1517-06-30 <int64> <int64> <bool> <datetime64[D]> >>> f.to_json_records(indent=4) [ { "a": 10, "b": false, "c": "1517-01-01" }, { "a": 2, "b": true, "c": "1517-04-01" }, { "a": 8, "b": true, "c": "1517-12-31" }, { "a": 3, "b": false, "c": "1517-06-30" } ]
- Frame.to_json_split(indent=None)[source]
Export a
Frame
as a JSON string constructed as follows: A JSON object with a key for “columns”, “index”, and “data”, where data is given as an array of arrays of row values.- Parameters:
indent – If indent is a non-negative integer or string, then JSON array elements and object members will be pretty-printed with that indent level.
>>> f = sf.Frame.from_fields(((10, 2, 8, 3), (False, True, True, False), ('1517-01-01', '1517-04-01', '1517-12-31', '1517-06-30')), columns=('a', 'b', 'c'), dtypes=dict(c=np.datetime64), name='x') >>> f <Frame: x> <Index> a b c <<U1> <Index> 0 10 False 1517-01-01 1 2 True 1517-04-01 2 8 True 1517-12-31 3 3 False 1517-06-30 <int64> <int64> <bool> <datetime64[D]> >>> f.to_json_split(indent=4) { "columns": [ "a", "b", "c" ], "index": [ 0, 1, 2, 3 ], "data": [ [ 10, false, "1517-01-01" ], [ 2, true, "1517-04-01" ], [ 8, true, "1517-12-31" ], [ 3, false, "1517-06-30" ] ] }
- Frame.to_json_typed(indent=None)[source]
Export a
Frame
as a JSON string constructed as follows: A JSON object with a key for “columns”, “index”, and “data”, where data is given as an array of arrays of column values; additionally, a key for “__meta__” defines an object with complete metadata and typing information.- Parameters:
indent – If indent is a non-negative integer or string, then JSON array elements and object members will be pretty-printed with that indent level.
>>> f = sf.Frame.from_fields(((10, 2, 8, 3), (False, True, True, False), ('1517-01-01', '1517-04-01', '1517-12-31', '1517-06-30')), columns=('a', 'b', 'c'), dtypes=dict(c=np.datetime64), name='x') >>> f <Frame: x> <Index> a b c <<U1> <Index> 0 10 False 1517-01-01 1 2 True 1517-04-01 2 8 True 1517-12-31 3 3 False 1517-06-30 <int64> <int64> <bool> <datetime64[D]> >>> f.to_json_typed(indent=4) { "columns": [ "a", "b", "c" ], "index": null, "data": [ [ 10, 2, 8, 3 ], [ false, true, true, false ], [ "1517-01-01", "1517-04-01", "1517-12-31", "1517-06-30" ] ], "__meta__": { "__names__": [ "x", null, null ], "__dtypes__": [ "=i8", "|b1", "=M8[D]" ], "__dtypes_index__": [ "=i8" ], "__dtypes_columns__": [ "=U1" ], "__types__": [ "Index", "Index" ], "__depths__": [ 3, 1, 1 ] } }
- Frame.to_json_values(indent=None)[source]
Export a
Frame
as a JSON string constructed as follows: A JSON array of arrays of row values; no index or columns labels are included.- Parameters:
indent – If indent is a non-negative integer or string, then JSON array elements and object members will be pretty-printed with that indent level.
>>> f = sf.Frame.from_fields(((10, 2, 8, 3), (False, True, True, False), ('1517-01-01', '1517-04-01', '1517-12-31', '1517-06-30')), columns=('a', 'b', 'c'), dtypes=dict(c=np.datetime64), name='x') >>> f <Frame: x> <Index> a b c <<U1> <Index> 0 10 False 1517-01-01 1 2 True 1517-04-01 2 8 True 1517-12-31 3 3 False 1517-06-30 <int64> <int64> <bool> <datetime64[D]> >>> f.to_json_values(indent=4) [ [ 10, false, "1517-01-01" ], [ 2, true, "1517-04-01" ], [ 8, true, "1517-12-31" ], [ 3, false, "1517-06-30" ] ]
- Frame.to_latex(config=None)[source]
Display the Frame as a LaTeX formatted table.
>>> f = sf.Frame.from_fields(((10, 2, 8, 3), ('qrs ', 'XYZ', '123', ' wX ')), columns=('a', 'b'), index=('p', 'q', 'r', 's'), name='x') >>> f <Frame: x> <Index> a b <<U1> <Index> p 10 qrs q 2 XYZ r 8 123 s 3 wX <<U1> <int64> <<U4> >>> f.to_latex() \begin{table}[ht] \centering \begin{tabular}{c c c} \hline\hline & a & b \\ \hline p & 10 & qrs \\ q & 2 & XYZ \\ r & 8 & 123 \\ s & 3 & wX \\ \hline\end{tabular} \end{table}
- Frame.to_markdown(config=None)[source]
Display the Frame as a Markdown formatted table.
>>> f = sf.Frame.from_fields(((10, 2, 8, 3), ('qrs ', 'XYZ', '123', ' wX ')), columns=('a', 'b'), index=('p', 'q', 'r', 's'), name='x') >>> f <Frame: x> <Index> a b <<U1> <Index> p 10 qrs q 2 XYZ r 8 123 s 3 wX <<U1> <int64> <<U4> >>> f.to_markdown() | |a |b | |--|---|----| |p |10 |qrs | |q |2 |XYZ | |r |8 |123 | |s |3 | wX |
- Frame.to_msgpack()[source]
Return msgpack bytes.
>>> f = sf.Frame.from_fields(((10, 2, 8, 3), ('qrs ', 'XYZ', '123', ' wX ')), columns=('a', 'b'), index=('p', 'q', 'r', 's'), name='x') >>> f <Frame: x> <Index> a b <<U1> <Index> p 10 qrs q 2 XYZ r 8 123 s 3 wX <<U1> <int64> <<U4> >>> f.to_msgpack() b'\x85\xc4\x02sf\xa5Frame\xc4\x04name\xa1x\xc4\x06blocks\xc4\xcd\x82\xc4\x02sf\xaaTypeBlocks\xc4\x06blocks\xc4\xb3\x92\x85\xc4\x02nd\xc3\xc4\x04type\xa3<i8\xc4\x04kind\xc4\x00\xc4\x05shape\x91\x04\xc4\x04data\xc4 \n\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00\x00\x00\x00\x00\x00\x08\x00\x00\x00\x00\x00\x00\x00\x03\x00\x00\x00\x00\x00\x00\x00\x85\xc4\x02nd\xc3\xc4\x04type\xa3<U4\xc4\x04kind\xc4\x00\xc4\x05shape\x91\x04\xc4\x04data\xc4@q\x00\x00\x00r\x00\x00\x00s\x00\x00\x00 \x00\x00\x00X\x00\x00\x00Y\x00\x00\x00Z\x00\x00\x00\x00\x00\x00\x001\x00\x00\x002\x00\x00\x003\x00\x00\x00\x00\x00\x00\x00 \x00\x00\x00w\x00\x00\x00X\x00\x00\x00 \x00\x00\x00\xc4\x05index\xc4S\x83\xc4\x02sf\xa5Index\xc4\x04name\xc0\xc4\x04data\xc49\x85\xc4\x02nd\xc3\xc4\x04type\xa3<U1\xc4\x04kind\xc4\x00\xc4\x05shape\x91\x04\xc4\x04data\xc4\x10p\x00\x00\x00q\x00\x00\x00r\x00\x00\x00s\x00\x00\x00\xc4\x07columns\xc4K\x83\xc4\x02sf\xa5Index\xc4\x04name\xc0\xc4\x04data\xc41\x85\xc4\x02nd\xc3\xc4\x04type\xa3<U1\xc4\x04kind\xc4\x00\xc4\x05shape\x91\x02\xc4\x04data\xc4\x08a\x00\x00\x00b\x00\x00\x00'
- Frame.to_npy(fp, *, include_index=True, include_columns=True, consolidate_blocks=False)[source]
Write a
Frame
as a directory of npy file.>>> f1 = sf.Frame.from_fields(((10, 2, 8, 3), (False, True, True, False), ('1517-01-01', '1517-04-01', '1517-12-31', '1517-06-30')), columns=('a', 'b', 'c'), dtypes=dict(c=np.datetime64), name='x') >>> f1 <Frame: x> <Index> a b c <<U1> <Index> 0 10 False 1517-01-01 1 2 True 1517-04-01 2 8 True 1517-12-31 3 3 False 1517-06-30 <int64> <int64> <bool> <datetime64[D]> >>> f1.to_npy('/tmp/f.npy') >>> sf.Frame.from_npy('/tmp/f.npy') <Frame: x> <Index> a b c <<U1> <Index> 0 10 False 1517-01-01 1 2 True 1517-04-01 2 8 True 1517-12-31 3 3 False 1517-06-30 <int64> <int64> <bool> <datetime64[D]> >>> import shutil >>> shutil.rmtree('/tmp/f.npy')
- Frame.to_npz(fp, *, include_index=True, include_columns=True, consolidate_blocks=False)[source]
Write a
Frame
as an npz file.>>> f1 = sf.Frame.from_fields(((10, 2, 8, 3), (False, True, True, False), ('1517-01-01', '1517-04-01', '1517-12-31', '1517-06-30')), columns=('a', 'b', 'c'), dtypes=dict(c=np.datetime64), name='x') >>> f1 <Frame: x> <Index> a b c <<U1> <Index> 0 10 False 1517-01-01 1 2 True 1517-04-01 2 8 True 1517-12-31 3 3 False 1517-06-30 <int64> <int64> <bool> <datetime64[D]> >>> f1.to_npz('/tmp/f.npz') >>> sf.Frame.from_npz('/tmp/f.npz') <Frame: x> <Index> a b c <<U1> <Index> 0 10 False 1517-01-01 1 2 True 1517-04-01 2 8 True 1517-12-31 3 3 False 1517-06-30 <int64> <int64> <bool> <datetime64[D]>
- Frame.to_pairs(axis=0)[source]
Return a tuple of major axis key, minor axis key vlaue pairs, where major axis is determined by the axis argument. Note that the returned object is eagerly constructed; use an iterator interface for lazy iteration.
>>> f = sf.Frame.from_fields(((10, 2, 8, 3), ('qrs ', 'XYZ', '123', ' wX ')), columns=('a', 'b'), index=('p', 'q', 'r', 's'), name='x') >>> f <Frame: x> <Index> a b <<U1> <Index> p 10 qrs q 2 XYZ r 8 123 s 3 wX <<U1> <int64> <<U4> >>> f.to_pairs() (('a', (('p', 10), ('q', 2), ('r', 8), ('s', 3))), ('b', (('p', 'qrs '), ('q', 'XYZ'), ('r', '123'), ('s', ' wX '))))
- Frame.to_pandas()[source]
Return a Pandas DataFrame.
>>> f = sf.Frame.from_fields(((10, 2, 8, 3), ('qrs ', 'XYZ', '123', ' wX ')), columns=('a', 'b'), index=('p', 'q', 'r', 's'), name='x') >>> f <Frame: x> <Index> a b <<U1> <Index> p 10 qrs q 2 XYZ r 8 123 s 3 wX <<U1> <int64> <<U4> >>> f.to_pandas() a b p 10 qrs q 2 XYZ r 8 123 s 3 wX
- Frame.to_parquet(fp, *, include_index=True, include_index_name=True, include_columns=True, include_columns_name=False)[source]
Write an Arrow Parquet binary file.
>>> f1 = sf.Frame(np.arange(6).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='x') >>> f1 <Frame: x> <Index> a b <<U1> <Index> p 0 1 q 2 3 r 4 5 <<U1> <int64> <int64> >>> f1.to_parquet('/tmp/f.parquet')
- Frame.to_pickle(fp, *, protocol=None)[source]
Write a
Frame
as a Python pickle.The pickle module is not secure. Only unpickle data you trust.
- Parameters:
fp – file path to write.
protocol – Pickle protocol to use.
>>> f1 = sf.Frame.from_fields(((10, 2, 8, 3), (False, True, True, False), ('1517-01-01', '1517-04-01', '1517-12-31', '1517-06-30')), columns=('a', 'b', 'c'), dtypes=dict(c=np.datetime64), name='x') >>> f1 <Frame: x> <Index> a b c <<U1> <Index> 0 10 False 1517-01-01 1 2 True 1517-04-01 2 8 True 1517-12-31 3 3 False 1517-06-30 <int64> <int64> <bool> <datetime64[D]> >>> f1.to_pickle('/tmp/f.pickle') >>> sf.Frame.from_pickle('/tmp/f.pickle') <Frame: x> <Index> a b c <<U1> <Index> 0 10 False 1517-01-01 1 2 True 1517-04-01 2 8 True 1517-12-31 3 3 False 1517-06-30 <int64> <int64> <bool> <datetime64[D]>
- Frame.to_rst(config=None)[source]
Display the Frame as an RST formatted table.
>>> f = sf.Frame.from_fields(((10, 2, 8, 3), ('qrs ', 'XYZ', '123', ' wX ')), columns=('a', 'b'), index=('p', 'q', 'r', 's'), name='x') >>> f <Frame: x> <Index> a b <<U1> <Index> p 10 qrs q 2 XYZ r 8 123 s 3 wX <<U1> <int64> <<U4> >>> f.to_rst() +--+---+----+ | |a |b | +==+===+====+ |p |10 |qrs | +--+---+----+ |q |2 |XYZ | +--+---+----+ |r |8 |123 | +--+---+----+ |s |3 | wX | +--+---+----+
- Frame.to_series(*, index_constructor=<class 'static_frame.core.index.Index'>, name=<object object>)[source]
Return a
Series
representation of thisFrame
, where the index is extended with columns to from tuple labels for each element in theFrame
.- Parameters:
index_constructor – Index constructor of the tuples produced by combining index and columns into one label. Providing
IndexHierarchy.from_labels
will produce a hierarchical index.
>>> f = sf.Frame.from_fields(((10, 2, 8, 3), ('qrs ', 'XYZ', '123', ' wX ')), columns=('a', 'b'), index=('p', 'q', 'r', 's'), name='x') >>> f <Frame: x> <Index> a b <<U1> <Index> p 10 qrs q 2 XYZ r 8 123 s 3 wX <<U1> <int64> <<U4> >>> f.to_series() <Series: x> <Index> ('p', 'a') 10 ('p', 'b') qrs ('q', 'a') 2 ('q', 'b') XYZ ('r', 'a') 8 ('r', 'b') 123 ('s', 'a') 3 ('s', 'b') wX <object> <object>
- Frame.to_sqlite(fp, *, label=<object object>, include_index=True, include_columns=True)[source]
Write the Frame as single-table SQLite file.
>>> f1 = sf.Frame.from_fields(((10, 2, 8, 3), (False, True, True, False), ('1517-01-01', '1517-04-01', '1517-12-31', '1517-06-30')), columns=('a', 'b', 'c'), dtypes=dict(c=np.datetime64), name='x') >>> f1 <Frame: x> <Index> a b c <<U1> <Index> 0 10 False 1517-01-01 1 2 True 1517-04-01 2 8 True 1517-12-31 3 3 False 1517-06-30 <int64> <int64> <bool> <datetime64[D]> >>> f1.to_sqlite('/tmp/f.db') >>> import sqlite3 >>> conn = sqlite3.connect('/tmp/f.db') >>> sf.Frame.from_sql("select * from x limit 2", connection=conn, index_depth=1) <Frame> <Index> a b c <<U1> <Index> 0 10 0 1517-01-01 1 2 1 1517-04-01 <int64> <int64> <int64> <<U10>
- Frame.to_tsv(fp, *, include_index=True, include_index_name=True, include_columns=True, include_columns_name=False, encoding=None, line_terminator='\n', quote_char='"', quote_double=True, escape_char=None, quoting=0, store_filter=<static_frame.core.store_filter.StoreFilter object>)[source]
Given a file path or file-like object, write the
Frame
as delimited text. The delimiter is set to a tab.- Parameters:
path (A file) –
instance (PathLib) –
object. (or file-like) –
* –
include_index – If True, the index will be written.
include_index_name – If including columns, populate the row above the index with the index
name
. Cannot be True ifinclude_columns_name
isTrue
.include_columns – If
True
, the columns will be written.include_columns_name – If including index, populate the column to the left of the columns with the columns
name
. Cannot be True ifinclude_index_name
is True.encoding – Encoding type to be used when opening the file.
line_terminator – The string used to terminate lines.
quote_char – A one-character string used to quote fields containing special characters, such as the
delimiter
orquote_char
, or which contain new-line characters.quote_double – Controls how instances of quote_char appearing inside a field should themselves be quoted. When
True
, the character is doubled. WhenFalse
, theescape_char
is used as a prefix to thequote_char
. It defaults to True.escape_char – A one-character string used by the writer to escape the delimiter if quoting is set to QUOTE_NONE and the quotechar if quote_double is False.
quoting – Controls when quotes should be generated. It can take on any of the QUOTE_* constants from the standard library csv module.
store_filter – A
StoreFilter
instance.
>>> f1 = sf.Frame(np.arange(6).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='x') >>> f1 <Frame: x> <Index> a b <<U1> <Index> p 0 1 q 2 3 r 4 5 <<U1> <int64> <int64> >>> f1.to_tsv('/tmp/f.tsv') >>> from pathlib import Path >>> Path('/tmp/f.tsv').read_text() __index0__ a b p 0 1 q 2 3 r 4 5
- Frame.to_visidata()
Open an interactive VisiData session.
- Frame.to_xarray()[source]
Return an xarray Dataset.
In order to preserve columnar types, and following the precedent of Pandas, the
Frame
, with a 1D index, is translated as a Dataset of 1D arrays, where each DataArray is a 1D array. If the index is anIndexHierarchy
, each column is mapped into an ND array of shape equal to the unique values found at each depth of the index.>>> f = sf.Frame.from_fields(((10, 2, 8, 3), ('qrs ', 'XYZ', '123', ' wX ')), columns=('a', 'b'), index=('p', 'q', 'r', 's'), name='x') >>> f <Frame: x> <Index> a b <<U1> <Index> p 10 qrs q 2 XYZ r 8 123 s 3 wX <<U1> <int64> <<U4> >>> f.to_xarray() <xarray.Dataset> Dimensions: (__index0__: 4) Coordinates: * __index0__ (__index0__) <U1 'p' 'q' 'r' 's' Data variables: a (__index0__) int64 10 2 8 3 b (__index0__) <U4 'qrs ' 'XYZ' '123' ' wX '
- Frame.to_xlsx(fp, *, label=<object object>, include_index=True, include_index_name=True, include_columns=True, include_columns_name=False, merge_hierarchical_labels=True, store_filter=<static_frame.core.store_filter.StoreFilter object>)[source]
Write the Frame as single-sheet XLSX file.
>>> f1 = sf.Frame(np.arange(6).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='x') >>> f1 <Frame: x> <Index> a b <<U1> <Index> p 0 1 q 2 3 r 4 5 <<U1> <int64> <int64> >>> f1.to_xlsx('/tmp/f.xlsx')
Frame: Constructor | Exporter | Attribute | Method | Dictionary-Like | Display | Assignment | Selector | Iterator | Operator Binary | Operator Unary | Accessor Values | Accessor Datetime | Accessor String | Accessor Transpose | Accessor Fill Value | Accessor Regular Expression | Accessor Hashlib | Accessor Type Clinic | Accessor Reduce