求你了,我想在一个数据帧中找到in client的最后一个值,我该怎么做?你知道吗
示例:
df = pd.DataFrame({'date': ['2018-06-13', '2018-06-14', '2018-06-15', '2018-06-16'], 'gain': [[10, 12, 15],[14, 11, 15],[9, 10, 12], [6, 4, 2]], 'how': [['customer1', 'customer2', 'customer3'], ['customer4','customer5','customer6' ], ['customer7', 'customer8', 'customer9'], ['customer5', 'customer6', 'customer10'] ]} df : date gain how 0 2018-06-13 [10, 12, 15] [customer1, customer2, customer3] 1 2018-06-14 [14, 11, 15] [customer4, customer5, customer6] 2 2018-06-15 [9, 10, 12] [customer7, customer8, customer9] 3 2018-06-16 [6, 4, 2] [customer5, customer6, customer10]
I want to do a function that returns the last gain in the dataframe.
example :
for the customer5 = 6
for the customer4 = 14
for the customer20 = 'not found'
非常感谢
然后使用unnesting函数,
drop_duplicates
然后用
reindex
输入搜索列表关于这类问题解答的有趣读物
How do I unnest a column in a pandas DataFrame?
相关问题 更多 >
编程相关推荐