datatable.cbind()¶
Create a new Frame by appending columns from several frames
.
Note
In contrast to dt.Frame.cbind()
that modifies
the original Frame in-place and returns None
,
this function returns a new Frame and do not modify any
of the frames
.
Therefore,
DT = dt.cbind(*frames, force=force)
is exactly equivalent to
DT = dt.Frame()
DT.cbind(*frames, force=force)
Parameters¶
Frame
| List[Frame]
| None
The list/tuple/sequence/generator expression of Frames to append.
It may also contain None
values, which will be simply
skipped.
bool
If True
, allows Frames to be appended even if they have unequal
number of rows. The resulting Frame will have number of rows equal
to the largest among all Frames. Those Frames which have less
than the largest number of rows, will be padded with NAs (with the
exception of Frames having just 1 row, which will be replicated
instead of filling with NAs).
Frame
A new frame that is created by appending columns from frames
.
See also¶
rbind()
– function for row-binding several frames.dt.Frame.cbind()
– Frame method for cbinding several frames to another.
Examples¶
from datatable import dt, f
DT = dt.Frame(A=[1, 2, 3], B=[4, 7, 0])
DT
A | B | ||
---|---|---|---|
int32 | int32 | ||
0 | 1 | 4 | |
1 | 2 | 7 | |
2 | 3 | 0 |
frame1 = dt.Frame(N=[-1, -2, -5])
frame1
N | ||
---|---|---|
int32 | ||
0 | -1 | |
1 | -2 | |
2 | -5 |
dt.cbind([DT, frame1])
A | B | N | ||
---|---|---|---|---|
int32 | int32 | int32 | ||
0 | 1 | 4 | -1 | |
1 | 2 | 7 | -2 | |
2 | 3 | 0 | -5 |
If the number of rows are not equal, you can force the binding by setting
the force
parameter to True
:
frame2 = dt.Frame(N=[-1, -2, -5, -20])
frame2
N | ||
---|---|---|
int32 | ||
0 | -1 | |
1 | -2 | |
2 | -5 | |
3 | -20 |
dt.cbind([DT, frame2], force=True)
A | B | N | ||
---|---|---|---|---|
int32 | int32 | int32 | ||
0 | 1 | 4 | -1 | |
1 | 2 | 7 | -2 | |
2 | 3 | 0 | -5 | |
3 | NA | NA | -20 |