koalas
koalas copied to clipboard
Not support rename DataFrame.columns assigning directly.
when rename columns of DataFrame,
pandas are supporting below way,
>>> pdf = pd.DataFrame({
... 'a': [1, 2, 3, 4, 5, 6, 7, 8, 9],
... 'b': [4, 5, 6, 3, 2, 1, 0, 0, 0]
... }, index=[0, 1, 3, 5, 6, 8, 9, 9, 9])
>>> pdf.columns
Index(['a', 'b'], dtype='object')
>>> pdf.columns.name = 'column_renamed'
>>> pdf.columns
Index(['a', 'b'], dtype='object', name='column_renamed')
but koalas not.
>>> kdf = ks.DataFrame({
... 'a': [1, 2, 3, 4, 5, 6, 7, 8, 9],
... 'b': [4, 5, 6, 3, 2, 1, 0, 0, 0]
... }, index=[0, 1, 3, 5, 6, 8, 9, 9, 9])
>>> kdf.columns
Index(['a', 'b'], dtype='object')
>>> kdf.columns.name = 'column_renamed'
>>> kdf.columns
Index(['a', 'b'], dtype='object')
FYI.
koalas can change name of columns like this,
>>> kdf.columns = kdf.columns.rename('column_renamed')
or like that
>>> tmp_columns = kdf.columns
>>> tmp_columns.name = 'column_renamed'
>>> kdf.columns = tmp_columns
but i think both ways are complicated than below
kdf.columns.name = 'column_renamed'