Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions examples/Microsoft.Spark.CSharp.Examples/Sql/Batch/Basic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,25 @@ public void Run(string[] args)

DataFrame joinedDf3 = df.Join(df, df["name"] == df["name"], "outer");
joinedDf3.Show();

// Union of two data frames
DataFrame unionDf = df.Union(df);
unionDf.Show();

// Add new column to data frame
df.WithColumn("location", Lit("Seattle")).Show();

// Rename existing column
df.WithColumnRenamed("name", "fullname").Show();

// Filter rows with null age
df.Filter(Col("age").IsNull()).Show();

// Fill null values in age column with -1
df.Na().Fill(-1, new[] { "age" }).Show();

// Drop age column
df.Drop(new[] { "age" }).Show();

spark.Stop();
}
Expand Down
19 changes: 19 additions & 0 deletions examples/Microsoft.Spark.FSharp.Examples/Sql/Basic.fs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,25 @@ type Basic() =

let joinedDf3 = df.Join(df, df.["name"].EqualTo(df.["name"]), "outer")
joinedDf3.Show()

// Union of two data frames
let unionDf = df.Union(df)
unionDf.Show()

// Add new column to data frame
df.WithColumn("location", Functions.Lit("Seattle")).Show()

// Rename existing column
df.WithColumnRenamed("name", "fullname").Show()

// Filter rows with null age
df.Filter(df.["age"].IsNull()).Show()

// Fill null values in age column with -1
df.Na().Fill(-1L, ["age"]).Show()

// Drop age column
df.Drop(df.["age"]).Show()

spark.Stop()
0
Expand Down