pub fn new<S: IntoSeries>(columns: Vec<S>) -> Result<Self> {
        let mut first_len = None;
        let mut series_cols = Vec::with_capacity(columns.len());
        let mut names = HashSet::with_capacity_and_hasher(columns.len(), RandomState::default());

        // check for series length equality and convert into series in one pass
        for s in columns {
            let series = s.into_series();
            match first_len {
                Some(len) => {
                    if series.len() != len {
                        return Err(PolarsError::ShapeMisMatch("Could not create a new DataFrame from Series. The Series have different lengths".into()));
                    }
                }
                None => first_len = Some(series.len()),
            }
            let name = series.name().to_string();

            if names.contains(&name) {
                return Err(PolarsError::Duplicate(
                    format!("Column with name: '{}' has more than one occurences", name).into(),
                ));
            }

            names.insert(name);
            series_cols.push(series)
        }
        let mut df = DataFrame {
            columns: series_cols,
        };
        df.rechunk()?;
        Ok(df)
    }
/// Create a DataFrame from a Vector of Series.
///
/// # Example
///
/// ```
/// use polars::prelude::*;
/// let s0 = Series::new("days", [0, 1, 2].as_ref());
/// let s1 = Series::new("temp", [22.1, 19.9, 7.].as_ref());
/// let df = DataFrame::new(vec![s0, s1]).unwrap();
/// ```
Create a DataFrame from a Vector of Series.
Create a DataFrame from a Vector of Series .
pub fn new<S: IntoSeries>(columns: Vec<S>) -> Result<Self> {
        let mut first_len = None;
        let mut series_cols = Vec::with_capacity(columns.len());
        let mut names = HashSet::with_capacity_and_hasher(columns.len(), RandomState::default());
        // check for series length equality and convert into series in one pass
        for s in columns {
            let series = s.into_series();
            match first_len {
                Some(len) => {
                    if series.len() != len {
                        return Err(PolarsError::ShapeMisMatch("Could not create a new DataFrame from Series. The Series have different lengths".into()));
                    }
                }
                None => first_len = Some(series.len()),
            }
            let name = series.name().to_string();
            if names.contains(&name) {
                return Err(PolarsError::Duplicate(
                    format!("Column with name: '{}' has more than one occurences", name).into(),
                ));
            }
            names.insert(name);
            series_cols.push(series)
        }
        let mut df = DataFrame {
            columns: series_cols,
        };
        df.rechunk()?;
        Ok(df)
    }
pub fn new < S : IntoSeries > ( columns : Vec < S > ) -> Result < Self > { let mut first_len = None ; let mut series_cols = Vec :: with_capacity ( columns . len ( ) ) ; let mut names = HashSet :: with_capacity_and_hasher ( columns . len ( ) , RandomState :: default ( ) ) ; // check for series length equality and convert into series in one pass for s in columns { let series = s . into_series ( ) ; match first_len { Some ( len ) => { if series . len ( ) != len { return Err ( PolarsError :: ShapeMisMatch ( " " . into ( ) ) ) ; } } None => first_len = Some ( series . len ( ) ) , } let name = series . name ( ) . to_string ( ) ; if names . contains ( & name ) { return Err ( PolarsError :: Duplicate ( format ! ( " " name ) . into ( ) , ) ) ; } names . insert ( name ) ; series_cols . push ( series ) } let mut df = DataFrame { columns : series_cols , } ; df . rechunk ( ) ? ; Ok ( df ) }
Create a DataFrame from a Vector of Series.
Create a DataFrame from a Vector of Series .
columns
Vec<S>
columns
Vec<S>
example
None