Add a new column to the frame. The frame will be initialized by the initializer. Parameters ---------- name : str The column name. scheme : Scheme The column scheme. ctx : DGLContext The column context.
(self, name, scheme, ctx)
| 710 | del self._columns[name] |
| 711 | |
| 712 | def add_column(self, name, scheme, ctx): |
| 713 | """Add a new column to the frame. |
| 714 | |
| 715 | The frame will be initialized by the initializer. |
| 716 | |
| 717 | Parameters |
| 718 | ---------- |
| 719 | name : str |
| 720 | The column name. |
| 721 | scheme : Scheme |
| 722 | The column scheme. |
| 723 | ctx : DGLContext |
| 724 | The column context. |
| 725 | """ |
| 726 | if name in self: |
| 727 | dgl_warning( |
| 728 | 'Column "%s" already exists. Ignore adding this column again.' |
| 729 | % name |
| 730 | ) |
| 731 | return |
| 732 | |
| 733 | if self.get_initializer(name) is None: |
| 734 | self._set_zero_default_initializer() |
| 735 | initializer = self.get_initializer(name) |
| 736 | init_data = initializer( |
| 737 | (self.num_rows,) + scheme.shape, |
| 738 | scheme.dtype, |
| 739 | ctx, |
| 740 | slice(0, self.num_rows), |
| 741 | ) |
| 742 | self._columns[name] = Column(init_data, scheme) |
| 743 | |
| 744 | def add_rows(self, num_rows): |
| 745 | """Add blank rows to this frame. |
no test coverage detected