Koalas: DataFrame.apply(func, axis=1)

Created on 27 Jan 2020  路  3Comments  路  Source: databricks/koalas

I'm missing the access of the whole row in the DataFrame.apply function, like

df = pd.DataFrame({"date":pd.to_datetime(['2012-01-01','2012-01-02']),
              "hour": [5, 5], 
              })

print(df)

df['datetime'] = df.apply(lambda x: x['date'].replace(hour=x['hour']), axis=1)

print(df)

Prints out:

        date  hour
0 2012-01-01     5
1 2012-01-02     5

        date  hour            datetime
0 2012-01-01     5 2012-01-01 05:00:00
1 2012-01-02     5 2012-01-02 05:00:00

We should implement DataFrame.apply(row_func, axis=1) using the UDFs.

enhancement

Most helpful comment

I'll start work on this soon. Maybe it will be impossible to support exactly same API but should be able to provide workaround.

All 3 comments

related to #65

I'll start work on this soon. Maybe it will be impossible to support exactly same API but should be able to provide workaround.

Was this page helpful?
0 / 5 - 0 ratings