Skip to content

Commit

Permalink
[Rust][Documentation] New example for DataFrame::get_columns (#1782)
Browse files Browse the repository at this point in the history
  • Loading branch information
ibENPC committed Nov 16, 2021
1 parent 12ff82f commit 7406567
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions polars/polars-core/src/frame/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,24 @@ impl DataFrame {
}

/// Get a reference to the DataFrame columns.
///
/// # Example
///
/// ```rust
/// use polars_core::df; // or "use polars::df"
/// use polars_core::prelude::*; // or "use polars::prelude::*"
///
/// fn example() -> Result<()> {
/// let df: DataFrame = df!("Name" => &["Adenine", "Cytosine", "Guanine", "Thymine"],
/// "Symbol" => &["A", "C", "G", "T"])?;
/// let columns: &Vec<Series> = df.get_columns();
///
/// assert_eq!(columns[0].name(), "Name");
/// assert_eq!(columns[1].name(), "Symbol");
///
/// Ok(())
/// }
/// ```
#[inline]
pub fn get_columns(&self) -> &Vec<Series> {
&self.columns
Expand Down

0 comments on commit 7406567

Please sign in to comment.