Generating pandas column values based upon filename
<p>I wish to populate three columns (day, week, year) in a pandas data frame.</p>

<p>The data is to be extracted from a filename which are in this format:</p>

<pre><code>AAAA_DDWWYYYY.txt
</code></pre>

<p>where:</p>

<ul>
<li>AAAA = alpha characters</li>
<li>DD = Day</li>
<li>WW = Month</li>
<li>YYYY = Year</li>
</ul>

<p>For example:</p>

<pre><code>NDVI_01012016.txt
</code></pre>

<p>is:</p>

<ul>
<li>Day = 01</li>
<li>Week = 01</li>
<li>Year = 2016</li>
</ul>

<p>Assuming <code>df</code> is your dataframe::</p>

<pre><code>df.ix[df.filename == 'NDVI_01012016.txt', 'Day'] = 1
df.ix[df.filename == 'NDVI_01012016.txt', 'Week'] = '01'
df.ix[df.filename == 'NDVI_01012016.txt', 'Year'] = '2016'
</code></pre>

python pandas