Detail: FrameGO: Exporter

Overview: FrameGO: Exporter

FrameGO.to_arrow(*, include_index=True, include_index_name=True, include_columns=True, include_columns_name=False)

Return a pyarrow.Table from this Frame.

>>> f = sf.FrameGO.from_fields(((10, 2, 8, 3), ('qrs ', 'XYZ', '123', ' wX ')), columns=('a', 'b'), index=('p', 'q', 'r', 's'), name='x')
>>> f
<FrameGO: x>
<IndexGO>    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 "]]
FrameGO.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>)

Given a file path or file-like object, write the Frame as delimited text. The delimiter 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 if include_columns_name is True.

  • 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 if include_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 or quote_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. When False, the escape_char is used as a prefix to the quote_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.FrameGO(np.arange(6).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='x')
>>> f1.to_clipboard()
FrameGO.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>)

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 if include_columns_name is True.

  • 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 if include_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 or quote_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. When False, the escape_char is used as a prefix to the quote_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.FrameGO(np.arange(6).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='x')
>>> f1
<FrameGO: x>
<IndexGO>    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

FrameGO.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>)

Given a file path or file-like object, write the Frame as delimited text. A delimiter 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 if include_columns_name is True.

  • 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 if include_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 or quote_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. When False, the escape_char is used as a prefix to the quote_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.FrameGO(np.arange(6).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='x')
>>> f1
<FrameGO: x>
<IndexGO>    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

FrameGO.to_frame(*, name=<object object>)

Return Frame instance from this Frame. If this Frame is immutable the same instance will be returned.

>>> f = sf.FrameGO.from_fields(((10, 2, 8, 3), ('qrs ', 'XYZ', '123', ' wX ')), columns=('a', 'b'), index=('p', 'q', 'r', 's'), name='x')
>>> f
<FrameGO: x>
<IndexGO>    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>
FrameGO.to_frame_go(*, name=<object object>)

Return a FrameGO instance from this Frame.

>>> f = sf.FrameGO.from_fields(((10, 2, 8, 3), ('qrs ', 'XYZ', '123', ' wX ')), columns=('a', 'b'), index=('p', 'q', 'r', 's'), name='x')
>>> f
<FrameGO: x>
<IndexGO>    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>
FrameGO.to_frame_he(*, name=<object object>)

Return a FrameHE instance from this Frame. If this Frame is immutable the same instance will be returned.

>>> f = sf.FrameGO.from_fields(((10, 2, 8, 3), ('qrs ', 'XYZ', '123', ' wX ')), columns=('a', 'b'), index=('p', 'q', 'r', 's'), name='x')
>>> f
<FrameGO: x>
<IndexGO>    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>
FrameGO.to_hdf5(fp, *, label=<object object>, include_index=True, include_columns=True)

Write the Frame as single-table SQLite file.

>>> f1 = sf.FrameGO(np.arange(6).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='x')
>>> f1
<FrameGO: x>
<IndexGO>    a       b       <<U1>
<Index>
p            0       1
q            2       3
r            4       5
<<U1>        <int64> <int64>
>>> f1.to_hdf5('/tmp/f.h5')
FrameGO.to_html(config=None, style_config=<static_frame.core.style_config.StyleConfig object>)

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

FrameGO.to_html_datatables(fp=None, show=True, config=None)

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.

FrameGO.to_json_columns(indent=None)

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.FrameGO.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
<FrameGO: x>
<IndexGO>    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"
    }
}
FrameGO.to_json_index(indent=None)

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.FrameGO.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
<FrameGO: x>
<IndexGO>    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"
    }
}
FrameGO.to_json_records(indent=None)

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.FrameGO.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
<FrameGO: x>
<IndexGO>    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"
    }
]
FrameGO.to_json_split(indent=None)

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.FrameGO.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
<FrameGO: x>
<IndexGO>    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"
        ]
    ]
}
FrameGO.to_json_typed(indent=None)

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.FrameGO.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
<FrameGO: x>
<IndexGO>    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",
            "IndexGO"
        ],
        "__depths__": [
            3,
            1,
            1
        ]
    }
}
FrameGO.to_json_values(indent=None)

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.FrameGO.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
<FrameGO: x>
<IndexGO>    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"
    ]
]
FrameGO.to_latex(config=None)

Display the Frame as a LaTeX formatted table.

>>> f = sf.FrameGO.from_fields(((10, 2, 8, 3), ('qrs ', 'XYZ', '123', ' wX ')), columns=('a', 'b'), index=('p', 'q', 'r', 's'), name='x')
>>> f
<FrameGO: x>
<IndexGO>    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}
FrameGO.to_markdown(config=None)

Display the Frame as a Markdown formatted table.

>>> f = sf.FrameGO.from_fields(((10, 2, 8, 3), ('qrs ', 'XYZ', '123', ' wX ')), columns=('a', 'b'), index=('p', 'q', 'r', 's'), name='x')
>>> f
<FrameGO: x>
<IndexGO>    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 |
FrameGO.to_msgpack()

Return msgpack bytes.

>>> f = sf.FrameGO.from_fields(((10, 2, 8, 3), ('qrs ', 'XYZ', '123', ' wX ')), columns=('a', 'b'), index=('p', 'q', 'r', 's'), name='x')
>>> f
<FrameGO: x>
<IndexGO>    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\xa7FrameGO\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\xc4M\x83\xc4\x02sf\xa7IndexGO\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'
FrameGO.to_npy(fp, *, include_index=True, include_columns=True, consolidate_blocks=False)

Write a Frame as a directory of npy file.

>>> f1 = sf.FrameGO.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
<FrameGO: x>
<IndexGO>    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')
FrameGO.to_npz(fp, *, include_index=True, include_columns=True, consolidate_blocks=False)

Write a Frame as an npz file.

>>> f1 = sf.FrameGO.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
<FrameGO: x>
<IndexGO>    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]>
FrameGO.to_pairs(axis=0)

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.FrameGO.from_fields(((10, 2, 8, 3), ('qrs ', 'XYZ', '123', ' wX ')), columns=('a', 'b'), index=('p', 'q', 'r', 's'), name='x')
>>> f
<FrameGO: x>
<IndexGO>    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 '))))
FrameGO.to_pandas()

Return a Pandas DataFrame.

>>> f = sf.FrameGO.from_fields(((10, 2, 8, 3), ('qrs ', 'XYZ', '123', ' wX ')), columns=('a', 'b'), index=('p', 'q', 'r', 's'), name='x')
>>> f
<FrameGO: x>
<IndexGO>    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 
FrameGO.to_parquet(fp, *, include_index=True, include_index_name=True, include_columns=True, include_columns_name=False)

Write an Arrow Parquet binary file.

>>> f1 = sf.FrameGO(np.arange(6).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='x')
>>> f1
<FrameGO: x>
<IndexGO>    a       b       <<U1>
<Index>
p            0       1
q            2       3
r            4       5
<<U1>        <int64> <int64>
>>> f1.to_parquet('/tmp/f.parquet')
FrameGO.to_pickle(fp, *, protocol=None)

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.FrameGO.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
<FrameGO: x>
<IndexGO>    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]>
FrameGO.to_rst(config=None)

Display the Frame as an RST formatted table.

>>> f = sf.FrameGO.from_fields(((10, 2, 8, 3), ('qrs ', 'XYZ', '123', ' wX ')), columns=('a', 'b'), index=('p', 'q', 'r', 's'), name='x')
>>> f
<FrameGO: x>
<IndexGO>    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 |
+--+---+----+
FrameGO.to_series(*, index_constructor=<class 'static_frame.core.index.Index'>, name=<object object>)

Return a Series representation of this Frame, where the index is extended with columns to from tuple labels for each element in the Frame.

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.FrameGO.from_fields(((10, 2, 8, 3), ('qrs ', 'XYZ', '123', ' wX ')), columns=('a', 'b'), index=('p', 'q', 'r', 's'), name='x')
>>> f
<FrameGO: x>
<IndexGO>    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>
FrameGO.to_sqlite(fp, *, label=<object object>, include_index=True, include_columns=True)

Write the Frame as single-table SQLite file.

>>> f1 = sf.FrameGO.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
<FrameGO: x>
<IndexGO>    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>
FrameGO.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>)

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 if include_columns_name is True.

  • 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 if include_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 or quote_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. When False, the escape_char is used as a prefix to the quote_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.FrameGO(np.arange(6).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='x')
>>> f1
<FrameGO: x>
<IndexGO>    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

FrameGO.to_visidata()

Open an interactive VisiData session.

FrameGO.to_xarray()

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 an IndexHierarchy, each column is mapped into an ND array of shape equal to the unique values found at each depth of the index.

>>> f = sf.FrameGO.from_fields(((10, 2, 8, 3), ('qrs ', 'XYZ', '123', ' wX ')), columns=('a', 'b'), index=('p', 'q', 'r', 's'), name='x')
>>> f
<FrameGO: x>
<IndexGO>    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 '
FrameGO.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>)

Write the Frame as single-sheet XLSX file.

>>> f1 = sf.FrameGO(np.arange(6).reshape(3,2), index=('p', 'q', 'r'), columns=('a', 'b'), name='x')
>>> f1
<FrameGO: x>
<IndexGO>    a       b       <<U1>
<Index>
p            0       1
q            2       3
r            4       5
<<U1>        <int64> <int64>
>>> f1.to_xlsx('/tmp/f.xlsx')

FrameGO: 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