Q:

Pandas lookup values from different columns

I'm looking for the best way of solving the following problem in Pandas.  Given a dataframe df, e.g.
import pandas as pd
dt = pd.date_range('1/1/2014', periods=10, freq='H')
df = pd.DataFrame({'A':[0.,0.,0.,1.,0.,0.,1.,0.,0.,0.],'B':[0.,0.,0.,0.,1.,0.,0.,0.,0.,1.]},index=dt)

df
                     A  B
2014-01-01 00:00:00  0  0
2014-01-01 01:00:00  0  0
2014-01-01 02:00:00  0  0
2014-01-01 03:00:00  1  0
2014-01-01 04:00:00  0  1
2014-01-01 05:00:00  0  0
2014-01-01 06:00:00  1  0
2014-01-01 07:00:00  0  0
2014-01-01 08:00:00  0  0
2014-01-01 09:00:00  0  1

then for each row where B=1 I would like to find the index of the last row before that where A=1, i.e.
                     A  B                    C
2014-01-01 04:00:00  0  1  2014-01-01 03:00:00
2014-01-01 09:00:00  0  1  2014-01-01 06:00:00

Not sure what the easiest way is to do this on Pandas while also being reasonably efficient for large dataframes.
Update:
Should have made clear in my original question that I'd like this to work where there is potentially more than one A=1 per B=1.  

A:

Here's one idea - there may be something better.
Populate a a column C with index values where A is 1.
df['C'] = np.where(df['A'] == 1, df.index, '')

Forward fill the missing values, so it represents that last time A was one.
df['C'] = df['C'].fillna(method='ffill')

Finally, fill all the values where B is not 1 with missing values.
df['C'] = np.where(df['B'] == 1, df['C'], '')

In [108]: df
Out[108]: 
                     A  B                   C
2014-01-01 00:00:00  0  0                 NaT
2014-01-01 01:00:00  0  0                 NaT
2014-01-01 02:00:00  0  0                 NaT
2014-01-01 03:00:00  1  0                 NaT
2014-01-01 04:00:00  0  1 2014-01-01 03:00:00
2014-01-01 05:00:00  0  0                 NaT
2014-01-01 06:00:00  1  0                 NaT
2014-01-01 07:00:00  0  0                 NaT
2014-01-01 08:00:00  0  0                 NaT
2014-01-01 09:00:00  0  1 2014-01-01 06:00:00

