nxcals.api.extraction.data.builders.DataFrame.alias
- DataFrame.alias(alias: str) DataFrame
Returns a new
DataFrame
with an alias set.New in version 1.3.0.
- Parameters:
alias (str) – an alias name to be set for the
DataFrame
.
Examples
>>> from pyspark.sql.functions import * >>> df_as1 = df.alias("df_as1") >>> df_as2 = df.alias("df_as2") >>> joined_df = df_as1.join(df_as2, col("df_as1.name") == col("df_as2.name"), 'inner') >>> joined_df.select("df_as1.name", "df_as2.name", "df_as2.age") .sort(desc("df_as1.name")).collect() [Row(name='Bob', name='Bob', age=5), Row(name='Alice', name='Alice', age=2)]