mirror of
https://github.com/nushell/nushell
synced 2024-12-27 21:43:09 +00:00
This reverts commit 3cb9147f22
.
This commit is contained in:
parent
14512988ba
commit
d86350af80
5 changed files with 9 additions and 43 deletions
|
@ -32,7 +32,7 @@ impl Command for AppendDF {
|
||||||
vec![
|
vec![
|
||||||
Example {
|
Example {
|
||||||
description: "Appends a dataframe as new columns",
|
description: "Appends a dataframe as new columns",
|
||||||
example: r#"let a = ([['a' 'b']; [1 2] [3 4]] | into df);
|
example: r#"let a = ([[a b]; [1 2] [3 4]] | into df);
|
||||||
$a | append $a"#,
|
$a | append $a"#,
|
||||||
result: Some(
|
result: Some(
|
||||||
NuDataFrame::try_from_columns(vec![
|
NuDataFrame::try_from_columns(vec![
|
||||||
|
@ -59,7 +59,7 @@ impl Command for AppendDF {
|
||||||
},
|
},
|
||||||
Example {
|
Example {
|
||||||
description: "Appends a dataframe merging at the end of columns",
|
description: "Appends a dataframe merging at the end of columns",
|
||||||
example: r#"let a = ([['a' 'b']; [1 2] [3 4]] | into df);
|
example: r#"let a = ([[a b]; [1 2] [3 4]] | into df);
|
||||||
$a | append $a --col"#,
|
$a | append $a --col"#,
|
||||||
result: Some(
|
result: Some(
|
||||||
NuDataFrame::try_from_columns(vec![
|
NuDataFrame::try_from_columns(vec![
|
||||||
|
|
|
@ -36,9 +36,9 @@ impl Command for DropNulls {
|
||||||
vec![
|
vec![
|
||||||
Example {
|
Example {
|
||||||
description: "drop null values in dataframe",
|
description: "drop null values in dataframe",
|
||||||
example: r#"let my_df = ([[a b]; [1 2] [3 0] [1 2]] | into df);
|
example: r#"let df = ([[a b]; [1 2] [3 0] [1 2]] | into df);
|
||||||
let res = ($my_df.b / $my_df.b);
|
let res = ($df.b / $df.b);
|
||||||
let a = ($my_df | with-column $res --name 'res');
|
let a = ($df | with-column $res --name res);
|
||||||
$a | drop-nulls"#,
|
$a | drop-nulls"#,
|
||||||
result: Some(
|
result: Some(
|
||||||
NuDataFrame::try_from_columns(vec![
|
NuDataFrame::try_from_columns(vec![
|
||||||
|
|
|
@ -38,9 +38,9 @@ impl Command for TakeDF {
|
||||||
vec![
|
vec![
|
||||||
Example {
|
Example {
|
||||||
description: "Takes selected rows from dataframe",
|
description: "Takes selected rows from dataframe",
|
||||||
example: r#"let my_df = ([[a b]; [4 1] [5 2] [4 3]] | into df);
|
example: r#"let df = ([[a b]; [4 1] [5 2] [4 3]] | into df);
|
||||||
let indices = ([0 2] | into df);
|
let indices = ([0 2] | into df);
|
||||||
$my_df | take $indices"#,
|
$df | take $indices"#,
|
||||||
result: Some(
|
result: Some(
|
||||||
NuDataFrame::try_from_columns(vec![
|
NuDataFrame::try_from_columns(vec![
|
||||||
Column::new(
|
Column::new(
|
||||||
|
|
|
@ -74,10 +74,6 @@ pub fn is_math_expression_like(
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if bytes == b"nu" {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
let b = bytes[0];
|
let b = bytes[0];
|
||||||
|
|
||||||
if b == b'('
|
if b == b'('
|
||||||
|
@ -119,11 +115,6 @@ pub fn is_math_expression_like(
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
let parsed_variable = parse_variable(working_set, span);
|
|
||||||
if parsed_variable.0.is_some() && parsed_variable.1.is_none() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4027,23 +4018,6 @@ pub fn parse_value(
|
||||||
return parse_variable_expr(working_set, span);
|
return parse_variable_expr(working_set, span);
|
||||||
}
|
}
|
||||||
|
|
||||||
let parsed_variable = parse_variable(working_set, span);
|
|
||||||
if parsed_variable.0.is_some() && parsed_variable.1.is_none() {
|
|
||||||
let var_id = parsed_variable
|
|
||||||
.0
|
|
||||||
.expect("internal error: already checked var id exists");
|
|
||||||
return (
|
|
||||||
Expression {
|
|
||||||
expr: Expr::Var(var_id),
|
|
||||||
span,
|
|
||||||
custom_completion: None,
|
|
||||||
ty: working_set.get_variable(var_id).ty.clone(),
|
|
||||||
},
|
|
||||||
None,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
let bytes = working_set.get_span_contents(span);
|
|
||||||
|
|
||||||
// Check for reserved keyword values
|
// Check for reserved keyword values
|
||||||
match bytes {
|
match bytes {
|
||||||
b"true" => {
|
b"true" => {
|
||||||
|
|
|
@ -1511,21 +1511,13 @@ impl<'a> StateWorkingSet<'a> {
|
||||||
pub fn find_variable(&self, name: &[u8]) -> Option<VarId> {
|
pub fn find_variable(&self, name: &[u8]) -> Option<VarId> {
|
||||||
let mut removed_overlays = vec![];
|
let mut removed_overlays = vec![];
|
||||||
|
|
||||||
let name = if name.starts_with(&[b'$']) {
|
|
||||||
name.to_vec()
|
|
||||||
} else {
|
|
||||||
let mut new_name = name.to_vec();
|
|
||||||
new_name.insert(0, b'$');
|
|
||||||
new_name
|
|
||||||
};
|
|
||||||
|
|
||||||
for scope_frame in self.delta.scope.iter().rev() {
|
for scope_frame in self.delta.scope.iter().rev() {
|
||||||
for overlay_frame in scope_frame
|
for overlay_frame in scope_frame
|
||||||
.active_overlays(&mut removed_overlays)
|
.active_overlays(&mut removed_overlays)
|
||||||
.iter()
|
.iter()
|
||||||
.rev()
|
.rev()
|
||||||
{
|
{
|
||||||
if let Some(var_id) = overlay_frame.vars.get(&name) {
|
if let Some(var_id) = overlay_frame.vars.get(name) {
|
||||||
return Some(*var_id);
|
return Some(*var_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1537,7 +1529,7 @@ impl<'a> StateWorkingSet<'a> {
|
||||||
.iter()
|
.iter()
|
||||||
.rev()
|
.rev()
|
||||||
{
|
{
|
||||||
if let Some(var_id) = overlay_frame.vars.get(&name) {
|
if let Some(var_id) = overlay_frame.vars.get(name) {
|
||||||
return Some(*var_id);
|
return Some(*var_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue