将函数应用于dataframe中的列

时间:2016-02-02 16:34:22

标签: pandas

我有一个包含许多列的数据框。我想在2列上应用一个函数。所以,我正在做

df[['Time','_Time']]

数据看起来像这样

                                   Time               _Time
Time                                                       
1998-05-21 09:00:36 1998-05-21 09:00:36 1998-05-21 09:53:38
1998-05-21 09:53:38 1998-05-21 09:53:38 1998-05-21 11:07:02
1998-05-21 11:07:02 1998-05-21 11:07:02 1998-05-21 13:09:39
1998-05-21 13:09:39 1998-05-21 13:09:39 1998-05-21 14:09:27
1998-05-21 14:09:27 1998-05-21 14:09:27 1998-05-21 15:15:00
1998-05-21 15:15:00 1998-05-21 15:15:00 1998-05-22 09:25:40
1998-05-22 09:25:40 1998-05-22 09:25:40 1998-05-22 10:37:39
1998-05-22 10:37:39 1998-05-22 10:37:39 1998-05-22 13:10:54

我想申请这个功能

def getInBetween(db="/tmp/f.db",product="/MSFT",start,stop):
  """start and stop are the time ranges. which will come from Time and _Time"""
  return {'high':highPrice,'low:lowPrice}

那么,如何为这两列应用getInBetween()?

0 个答案:

没有答案