MCPcopy Create free account
hub / github.com/apache/arrow-rs / remove_column

Method remove_column

arrow-array/src/record_batch.rs:668–673  ·  view source on GitHub ↗

Remove column by index and return it. Return the `ArrayRef` if the column is removed. # Panics Panics if `index`` out of bounds. # Example ``` use std::sync::Arc; use arrow_array::{BooleanArray, Int32Array, RecordBatch}; use arrow_schema::{DataType, Field, Schema}; let id_array = Int32Array::from(vec![1, 2, 3, 4, 5]); let bool_array = BooleanArray::from(vec![true, false, false, true, true]);

(&mut self, index: usize)

Source from the content-addressed store, hash-verified

666 /// assert_eq!(batch.num_columns(), 1);
667 /// ```
668 pub fn remove_column(&mut self, index: usize) -> ArrayRef {
669 let mut builder = SchemaBuilder::from(self.schema.as_ref());
670 builder.remove(index);
671 self.schema = Arc::new(builder.finish());
672 self.columns.remove(index)
673 }
674
675 /// Return a new RecordBatch where each column is sliced
676 /// according to `offset` and `length`

Calls 3

as_refMethod · 0.45
removeMethod · 0.45
finishMethod · 0.45