Pandas - Modify string values in each cell
<p>I have a pandas dataframe and I need to modify all values in a given string column.  Each column contains string values of the same length.  <strong>The user provides the index they want to be replaced for each value</strong></p>
<ul>
<li>for example: <code>[1:3]</code> and the replacement value <code>&quot;AAA&quot;</code>.</li>
<li>This would replace the string from values 1 to 3 with the value <code>AAA</code>.</li>
</ul>
<p>How can I use the <code>applymap()</code>, <code>map()</code> or <code>apply()</code> function to get this done?</p>
<hr />
<p>SOLUTION: Here is the final solution I went off of using the answer marked below:</p>
<pre><code>import pandas as pd

df = pd.DataFrame({'A':['ffgghh','ffrtss','ffrtds'],
                     #'B':['ffrtss','ssgghh','d'],
                     'C':['qqttss',' 44','f']})
print df
old = ['g', 'r', 'z']
new = ['y', 'b', 'c']
vals = dict(zip(old, new))

pos = 2
for old, new in vals.items():
    df.ix[df['A'].str[pos] == old, 'A'] = df['A'].str.slice_replace(pos,pos + len(new),new)
print df
</code></pre>