Skip to content

Instantly share code, notes, and snippets.

@wut0n9
Last active December 12, 2018 13:46
Show Gist options
  • Save wut0n9/004e2b20d4116314554ba5c56fc8c149 to your computer and use it in GitHub Desktop.
Save wut0n9/004e2b20d4116314554ba5c56fc8c149 to your computer and use it in GitHub Desktop.
# apply方法同时为多列赋值操作
import pandas as pd
df = pd.read_excel('test.xlsx',encoding='utf8')
df[['col2', 'col3']] = df.apply(lambda row: ps.Series(func(row[0])), axis=1)
def func(col1):
# 为col2和col3赋同一值
return col1, col1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment