Skip to content

Commit

Permalink
don't automatically rechunk dataframe;
Browse files Browse the repository at this point in the history
This was a very old design decision, but
turns out not to be needed. By not
having same chunks, we can for instance lag
columns for free. Every function implementation
decides if a rechunk is needed or not.
  • Loading branch information
ritchie46 committed Dec 19, 2021
1 parent eafba50 commit 1606cbc
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions polars/polars-core/src/frame/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -237,11 +237,9 @@ impl DataFrame {
series_cols
};

let mut df = DataFrame {
Ok(DataFrame {
columns: series_cols,
};
df.rechunk();
Ok(df)
})
}

/// Removes the last `Series` from the `DataFrame` and returns it, or [`None`] if it is empty.
Expand Down Expand Up @@ -639,7 +637,6 @@ impl DataFrame {
for col in columns {
self.columns.push(col.clone());
}
self.rechunk();
self
}

Expand Down Expand Up @@ -952,7 +949,6 @@ impl DataFrame {
fn insert_at_idx_no_name_check(&mut self, index: usize, series: Series) -> Result<&mut Self> {
if series.len() == self.height() {
self.columns.insert(index, series);
self.rechunk();
Ok(self)
} else {
Err(PolarsError::ShapeMisMatch(
Expand Down Expand Up @@ -981,7 +977,6 @@ impl DataFrame {
self.replace_at_idx(idx, series)?;
} else {
self.columns.push(series);
self.rechunk();
}
Ok(self)
} else {
Expand Down Expand Up @@ -1806,7 +1801,6 @@ impl DataFrame {
let col = self.columns.get_unchecked_mut(idx);
col.rename(&name);
}
self.rechunk();
Ok(self)
}

Expand Down Expand Up @@ -1874,7 +1868,6 @@ impl DataFrame {
let col = self.columns.get_unchecked_mut(idx);
col.rename(&name);
}
self.rechunk();
Ok(self)
}

Expand Down

0 comments on commit 1606cbc

Please sign in to comment.