title: Splitting column of dataframe to a new column in same dataframe in Pandas
body: <p>I am new to Python programming. I am trying to split a column from a dataframe <code>df</code> and add it as a new column to the same <code>df</code>. Below is a sample reproducible code for reference.</p>
  
  <pre><code>import pandas as pd
  import datetime
  
  # Create new dataframe df
  df = pd.DataFrame({'sample_date':['2018-01-10','2018-01-10','2018-01-11','2018-01-11','2018-01-12']})
  
  # Get current date. It is 2018-01-12 for me as I write this
  today = datetime.date.today()
  
  # Add new column to the df dataframe
  df['Today'] = today
  
  # Converting all columns to datetime dtype
  df['sample_date'] = pd.to_datetime(df['sample_date'])
  df['Today'] = pd.to_datetime(df['Today'])
  
  # Creating a new column to get difference of Today and sample_date column
  df['Difference'] = df['Today'] - df['sample_date']
  </code></pre>
  
  <p>When I write the df file to system as csv or txt, I can see the output as shown below.</p>
  
  <pre><code>sample_date Today       Difference
  10-01-2018  12-01-2018  2 days 00:00:00.000000000
  10-01-2018  12-01-2018  2 days 00:00:00.000000000
  11-01-2018  12-01-2018  1 days 00:00:00.000000000
  11-01-2018  12-01-2018  1 days 00:00:00.000000000
  12-01-2018  12-01-2018  0 days 00:00:00.000000000
  </code></pre>
  
  <p>I Want to add a new column <code>'Day'</code> to the same dataframe <code>df</code> by splitting the <code>'Difference'</code> column in such a way that only the values before days are captured. Something like the one shown below.</p>
  
  <pre><code># Desired output
  sample_date Today       Difference                  Day
  10-01-2018  12-01-2018  2 days 00:00:00.000000000   2
  10-01-2018  12-01-2018  2 days 00:00:00.000000000   2
  11-01-2018  12-01-2018  1 days 00:00:00.000000000   1
  11-01-2018  12-01-2018  1 days 00:00:00.000000000   1
  12-01-2018  12-01-2018  0 days 00:00:00.000000000   0
  </code></pre>
  
  <p>I have tried using the <code>str.split()</code> option using the solution provided in this thread - <a href="https://stackoverflow.com/questions/14745022/how-to-split-a-column-into-two-columns">How to split a column into two columns?</a>. But I am getting an error and not able to figure out what I am doing wrong. Is there any way I can get the desired output? I am using Python 3.6.4. Any help would be appreciated.</p>
  
  <p><strong><em>UPDATE:</em></strong></p>
  
  <p>I tried the solution provided by @Jonas Byström but the output is not what I am looking for. Any Idea what I may be doing wrong?</p>
  
  <pre><code># Trying a Solution
  df['Difference'] = str(df['Today'] - df['sample_date']).split()[0]
  
  # Output received
  
    sample_date      Today Difference
  0  2018-01-10 2018-01-12          0
  1  2018-01-10 2018-01-12          0
  2  2018-01-11 2018-01-12          0
  3  2018-01-11 2018-01-12          0
  4  2018-01-12 2018-01-12          0
  </code></pre>