enable to-nu to include the whole dfr if rows is not specified (#4753)

This commit is contained in:
Darren Schroeder 2022-03-06 09:04:41 -06:00 committed by GitHub
parent 69fd777120
commit 5ae5ef5146
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 1 deletions

View file

@ -71,7 +71,12 @@ fn command(
let values = if tail { let values = if tail {
df.tail(rows, call.head)? df.tail(rows, call.head)?
} else { } else {
df.head(rows, call.head)? // if rows is specified, return those rows, otherwise return everything
if rows.is_some() {
df.head(rows, call.head)?
} else {
df.head(Some(df.height()), call.head)?
}
}; };
let value = Value::List { let value = Value::List {

View file

@ -275,6 +275,10 @@ impl NuDataFrame {
} }
} }
pub fn height(&self) -> usize {
self.0.height()
}
pub fn head(&self, rows: Option<usize>, span: Span) -> Result<Vec<Value>, ShellError> { pub fn head(&self, rows: Option<usize>, span: Span) -> Result<Vec<Value>, ShellError> {
let to_row = rows.unwrap_or(5); let to_row = rows.unwrap_or(5);
let values = self.to_rows(0, to_row, span)?; let values = self.to_rows(0, to_row, span)?;