Skip to content

Commit

Permalink
add eager cookbook
Browse files Browse the repository at this point in the history
  • Loading branch information
ritchie46 committed May 26, 2021
1 parent c0f4991 commit b44a057
Show file tree
Hide file tree
Showing 7 changed files with 657 additions and 140 deletions.
2 changes: 1 addition & 1 deletion polars/polars-core/src/frame/groupby/pivot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ impl<'df, 'selection_str> GroupBy<'df, 'selection_str> {
/// let df = df!("foo" => &["A", "A", "B", "B", "C"],
/// "N" => &[1, 2, 2, 4, 2],
/// "bar" => &["k", "l", "m", "n", "0"]
/// ).unwrap();
/// )?;
///
/// df.groupby("foo")?
/// .pivot("bar", "N")
Expand Down
2 changes: 1 addition & 1 deletion polars/polars-core/src/frame/groupby/resample.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ impl DataFrame {
/// use polars_core::frame::groupby::resample::SampleRule;
///
/// fn example(df: &DataFrame) -> Result<DataFrame> {
/// df.downsample("datetime", SampleRule::Minute(6))?
/// df.downsample("datetime", SampleRule::Minute(5))?
/// .first()?
/// .sort("datetime", false)
/// }
Expand Down
32 changes: 32 additions & 0 deletions polars/polars-io/src/ipc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,21 @@ use std::io::{Read, Seek, Write};
use std::sync::Arc;

/// Read Arrows IPC format into a DataFrame
///
/// # Example
/// ```
/// use polars_core::prelude::*;
/// use std::fs::File;
/// use polars_io::ipc::IpcReader;
/// use polars_io::SerReader;
///
/// fn example() -> Result<DataFrame> {
/// let file = File::open("file.ipc").expect("file not found");
///
/// IpcReader::new(file)
/// .finish()
/// }
/// ```
pub struct IpcReader<R> {
/// File or Stream object
reader: R,
Expand Down Expand Up @@ -85,6 +100,23 @@ where
}

/// Write a DataFrame to Arrow's IPC format
///
/// # Example
///
/// ```
/// use polars_core::prelude::*;
/// use polars_io::ipc::IpcWriter;
/// use std::fs::File;
/// use polars_io::SerWriter;
///
/// fn example(df: &mut DataFrame) -> Result<()> {
/// let mut file = File::create("file.ipc").expect("could not create file");
///
/// IpcWriter::new(&mut file)
/// .finish(df)
/// }
///
/// ```
pub struct IpcWriter<'a, W> {
writer: &'a mut W,
}
Expand Down
4 changes: 4 additions & 0 deletions polars/polars-io/src/parquet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,10 @@ where
}

/// Write a DataFrame to parquet format
///
/// # Example
///
///
pub struct ParquetWriter<W> {
writer: W,
}
Expand Down

0 comments on commit b44a057

Please sign in to comment.