title: How to extract URL from Pandas DataFrame?
body: <p>I need to extract URLs from a column of DataFrame which was created using following values  </p>
  
  <pre><code>creation_date,tweet_id,tweet_text
  2020-06-06 03:01:37,1269102116364324865,#Webinar: Sign up for @SumoLogic's June 16 webinar to learn how to navigate your #Kubernetes environment and unders… https://stackoverflow.com/questions/42237666/extracting-information-from-pandas-dataframe
  2020-06-06 01:29:38,1269078966985461767,"In this #webinar replay, @DisneyStreaming's @rothgar chats with @SumoLogic's @BenoitNewton about how #Kubernetes is… https://stackoverflow.com/questions/46928636/pandas-split-list-into-columns-with-regex
  </code></pre>
  
  <p>column name <code>tweet_text</code> contains URL. I am trying following code.</p>
  
  <pre><code>df["tweet_text"]=df["tweet_text"].astype(str)
  pattern = r'https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&amp;//=]*)'
  
  df['links'] = ''
  df['links']= df["tweet_text"].str.extract(pattern, expand=True)
  
  print(df)
  </code></pre>
  
  <p>I am using regex from answer of <a href="https://stackoverflow.com/questions/3809401/what-is-a-good-regular-expression-to-match-a-url">this question</a> and it matches URL in both rows.<a href="https://i.stack.imgur.com/vVBSo.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/vVBSo.png" alt="screenshot"></a>
  But I am getting <code>NaN</code> as values of new column <code>df['links]'</code>. I have also tried solution provided in first answer of <a href="https://stackoverflow.com/questions/36028932/how-to-extract-specific-content-in-a-pandas-dataframe-with-a-regex">this question</a>, which was </p>
  
  <pre><code>df['links']= df["tweet_text"].str.extract(pattern, expand=False).str.strip()
  </code></pre>
  
  <p>But I am getting following error</p>
  
  <pre><code>AttributeError: 'DataFrame' object has no attribute 'str'
  </code></pre>
  
  <p>Lastly I created an empty column using <code>df['links'] = ''</code>, because I was getting <code>ValueError: Wrong number of items passed 2, placement implies 1</code> error. If that's relevant. 
  Can someone help me out here?</p>