Reputation: 71
According to the Polars documentation, in Python, you can vertically concatenate two data frames using the procedure shown in the below code snippet:
df_v1 = pl.DataFrame(
{
"a": [1],
"b": [3],
}
)
df_v2 = pl.DataFrame(
{
"a": [2],
"b": [4],
}
)
df_vertical_concat = pl.concat(
[
df_v1,
df_v2,
],
how="vertical",
)
print(df_vertical_concat)
The output of the above code is:
shape: (2, 2)
┌─────┬─────┐
│ a ┆ b │
│ --- ┆ --- │
│ i64 ┆ i64 │
╞═════╪═════╡
│ 1 ┆ 3 │
├╌╌╌╌╌┼╌╌╌╌╌┤
│ 2 ┆ 4 │
└─────┴─────┘
How do you perform the same operation in Rust?
Upvotes: 1
Views: 1969
Reputation: 71
You can do it as follows:
let df_vertical_concat = df_v1.vstack(&df_v2).unwrap();
Upvotes: 2