PySpark로 하는 Feature Engineering
John Hogue
Lead Data Scientist, General Mills
장점

단점

데이터 방향 정리

DataFrame.join(other, # 병합할 다른 DataFrameon=None, # 조인 키how=None) # 조인 유형 (기본값 'inner')
# Inspect dataframe head
hdf.show(2)
+----------+--------------------+
| dt| nm|
+----------+--------------------+
|2012-01-02| New Year Day|
|2012-01-16|Martin Luther Kin...|
+----------+--------------------+
only showing top 2 rows
# Specify join conditon cond = [df['OFFMARKETDATE'] == hdf['dt']]# Join two hdf onto df df = df.join(hdf, on=cond, 'left')# How many sales occurred on bank holidays? df.where(~df['nm'].isNull()).count()
0
# Register the dataframe as a temp table
df.createOrReplaceTempView("df")
hdf.createOrReplaceTempView("hdf")
# Write a SQL Statement
sql_df = spark.sql("""
SELECT
*
FROM df
LEFT JOIN hdf
ON df.OFFMARKETDATE = hdf.dt
""")
PySpark로 하는 Feature Engineering