Код: Выделить всё
import pandas as pd
import numpy as np
def myfunc(x, y):
return x + y
colNames = ['A', 'B']
data = np.array([np.arange(10)]*2).T
df = pd.DataFrame(data, index=range(0, 10), columns=colNames)
Код: Выделить всё
df['D'] = (df.apply(lambda x: myfunc(x.A, x.B), axis=1))
Код: Выделить всё
df['D'] = (df.apply(lambda x: myfunc(x.colNames[0], x.colNames[1]), axis=1))
Код: Выделить всё
AttributeError: ("'Series' object has no attribute 'colNames'", u'occurred at index 0')
Подробнее здесь: https://stackoverflow.com/questions/405 ... -attribute
Мобильная версия