除了序列对象的比较外,您选择的方法几乎很好。如果用x代替df\u analisis\u invertido,它应该可以工作。
举个例子:
import pandas as pd
data = {'t_first_conv': [5, 21, 233],
't_creation': [3, 23, 234],
}
df = pd.DataFrame(data)
df['t_first_conv'] = pd.to_datetime(df['t_first_conv'])
df['t_creation'] = pd.to_datetime(df['t_creation'])
print(df)
# Change entry of first conversion column in case it is older/smaller than creation value (timestamps)
# Expected:
# 0: 5 3
# 1: 23 23
# 2: 234 234
df['t_first_conv']=df.apply(lambda x: x['t_creation'] if x['t_first_conv'] < x['t_creation'] else x['t_first_conv'], axis=1)
print(df)