Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You are looking for <a href="http://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.apply.html?highlight=apply#pandas.DataFrame.apply" rel="noreferrer"><code>apply</code></a> <em>(<a href="http://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.merge.html?highlight=merge#pandas.DataFrame.merge" rel="noreferrer"><code>merge</code></a> is like a database join.):</em></p> <pre><code>In [1]: from pandas import DataFrame In [2]: df = DataFrame([[1,11,2012],[1,10,2012]], columns=['day','month','year']) In [3]: df Out[3]: day month year 0 1 11 2012 1 1 10 2012 In [4]: df.apply(lambda row: str(row['day'])+'/'+str(row['month'])+'/'+str(row['year']), axis=1) Out[4]: 0 1/11/2012 1 1/10/2012 </code></pre> <p><em>The <code>axis=1</code> part means you are selecting columns rather than row.</em></p> <p>If you wanted to give a specific date you could use datetime:</p> <pre><code>In [5]: import datetime In [6]: df.apply(lambda row: datetime.datetime(row['year'],row['month'],row['day']), axis=1) Out[6]: 0 2012-11-01 00:00:00 1 2012-10-01 00:00:00 </code></pre> <p>You can add these as columns in you dataframe as follows:</p> <pre><code>In [7]: df['new_date'] = df.apply(lambda row: str(row['day'])+'/'+str(row['month'])+'/'+str(row['year']), axis=1) In [8]: df Out[8]: day month year new_date 0 1 11 2012 1/11/2012 1 1 10 2012 1/10/2012 </code></pre> <p>.</p> <p><em>It's worth noting that pandas has an easy way to <a href="http://pandas.pydata.org/pandas-docs/stable/generated/pandas.io.parsers.read_csv.html" rel="noreferrer"><code>parse_dates</code> when reading as a csv</a>.</em></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload