enframe
In [1]:
Copied!
# https://tibble.tidyverse.org/reference/enframe.html
%run nb_helpers.py
from datar.tibble import *
from datar.base import seq
nb_header(enframe, deframe, book='enframe')
# https://tibble.tidyverse.org/reference/enframe.html
%run nb_helpers.py
from datar.tibble import *
from datar.base import seq
nb_header(enframe, deframe, book='enframe')
Try this notebook on binder.
★ enframe¶
Converts mappings or lists to one- or two-column data frames.¶
Args:¶
x
: a list, a dictionary or a dataframe with one or two columns
name
: and
value
: value Names of the columns that store the names and values.
If None
, a one-column dataframe is returned.
value
cannot be None
Returns:¶
A data frame with two columns if name
is not None (default) or
one-column otherwise.
★ deframe¶
In [2]:
Copied!
enframe(seq(1,3))
enframe(seq(1,3))
Out[2]:
name | value | |
---|---|---|
<int64> | <int64> | |
0 | 0 | 1 |
1 | 1 | 2 |
2 | 2 | 3 |
In [3]:
Copied!
enframe(dict(a=5, b=7))
enframe(dict(a=5, b=7))
Out[3]:
name | value | |
---|---|---|
<object> | <int64> | |
0 | a | 5 |
1 | b | 7 |
In [4]:
Copied!
enframe(dict(one=1, two=[2,3], three=[4,5,6]))
enframe(dict(one=1, two=[2,3], three=[4,5,6]))
Out[4]:
name | value | |
---|---|---|
<object> | <object> | |
0 | one | 1 |
1 | two | [2, 3] |
2 | three | [4, 5, 6] |
In [5]:
Copied!
deframe(enframe(seq(3,1)))
deframe(enframe(seq(3,1)))
Out[5]:
{0: 3, 1: 2, 2: 1}
In [6]:
Copied!
deframe(tibble(a=seq(1,3)))
deframe(tibble(a=seq(1,3)))
Out[6]:
array([1, 2, 3])
In [7]:
Copied!
deframe(tibble(a=[seq(1,3)]))
deframe(tibble(a=[seq(1,3)]))
Out[7]:
array([array([1, 2, 3])], dtype=object)