Skip to content

Commit

Permalink
impl FromIterator<Series> for DataFrame
Browse files Browse the repository at this point in the history
  • Loading branch information
ritchie46 committed Aug 27, 2020
1 parent 9f32ecd commit 50a6ebe
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions polars/src/frame/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use crate::prelude::*;
use arrow::datatypes::{Field, Schema};
use arrow::record_batch::RecordBatch;
use itertools::Itertools;
use itertools::__std_iter::FromIterator;
use rayon::prelude::*;
use std::mem;
use std::sync::Arc;
Expand Down Expand Up @@ -708,6 +709,16 @@ impl<'a> Iterator for RecordBatchIter<'a> {
}
}

impl FromIterator<Series> for DataFrame {
/// # Panics
///
/// Panics if Series have different lengths.
fn from_iter<T: IntoIterator<Item = Series>>(iter: T) -> Self {
let v = iter.into_iter().collect();
DataFrame::new(v).expect("could not create DataFrame from iterator")
}
}

#[cfg(test)]
mod test {
use crate::prelude::*;
Expand Down

0 comments on commit 50a6ebe

Please sign in to comment.