In [174]:
import pandas as pd

In [175]:
df = pd.read_csv("excuse.csv")

In [176]:
df


Out[176]:
excuse headline hyperlink
0 the fog was unexpected and did slow us down a bit De Blasio Blames 'Rough Night' and Fog for Mis... http://www.dnainfo.com/new-york/20141112/rocka...
1 we had some meetings at Gracie Mansion De Blasio 30 Minutes Late to Rockaway St. Patr... http://www.dnainfo.com/new-york/20150307/belle...
2 I had a very rough night and woke up sluggish De Blasio Blames 'Rough Night' and Fog for Mis... http://www.dnainfo.com/new-york/20141112/rocka...
3 I just woke up in the middle of the night and ... De Blasio Blames 'Rough Night' and Fog for Mis... http://www.dnainfo.com/new-york/20141112/rocka...
4 we had some stuff we had to do De Blasio 30 Minutes Late to Rockaway St. Patr... http://www.dnainfo.com/new-york/20150307/belle...
5 I should have gotten myself moving quicker De Blasio Blames 'Rough Night' and Fog for Mis... http://www.dnainfo.com/new-york/20141112/rocka...
6 I was just not feeling well this morning De Blasio Blames 'Rough Night' and Fog for Mis... http://www.dnainfo.com/new-york/20141112/rocka...
7 breakfast began a little later than expected De Blasio 15 Minutes Late to St. Patrick's Day... http://www.dnainfo.com/new-york/20150317/midto...
8 the detail drove away when we went into the su... Mayor de Blasio Is Irked by a Subway Delay http://www.nytimes.com/2015/05/06/nyregion/may...
9 we waited 20 mins for an express only to hear ... Mayor de Blasio Is Irked by a Subway Delay http://www.nytimes.com/2015/05/06/nyregion/may...
10 we need a better system Mayor de Blasio Is Irked by a Subway Delay http://www.nytimes.com/2015/05/06/nyregion/may...

In [177]:
df=df.reset_index()

In [179]:
df["hyperlink"].index


Out[179]:
RangeIndex(start=0, stop=11, step=1)

In [113]:
import random

In [180]:
def excuses(x):
    df = pd.read_csv("excuse.csv")
    ex = random.choice(df['excuse'])
    hl=df['hyperlink'][df[df['excuse']==ex].index]
    name = input("What's the name of the person you were supposed to meet: ")
    place = input("Where were you supposed to go: ")
    output = ("Sorry " + name + ", I was late to " + place + 
              " to meet you, " + ex + ".") 
    output2 = (hl)
    return output, output2

In [181]:
print(excuses(1))


What's the name of the person you were supposed to meet: aa
Where were you supposed to go: bb
('Sorry aa, I was late to bb to meet you, I had a very rough night and woke up sluggish.', 2    http://www.dnainfo.com/new-york/20141112/rocka...
Name: hyperlink, dtype: object)

In [ ]: