Q:

Python dataframe conditional column population

I need to populate values in a column based on whether or not values in a different column contain certain alphabets, and some rules. 
For example:
Here's my starting dataframe:
import pandas as pd
testdata1 = [('A', ['3c', '20b', '9']),
     ('B', ['Prod1', 'Prod2', 'Prod3']),
     ('C', ['', '', '']),
     ]
df = pd.DataFrame.from_items(testdata1)
df

Here's my target dataframe:
targetdf = [('A', ['3c', '20b', '9']),
     ('B', ['Prod1', 'Prod2', 'Prod3']),
     ('C', ['15.00', '40.00', '9']),
     ]
df2 = pd.DataFrame.from_items(targetdf)
df2

In my example above, if the cell in Column A contains 'c', the corresponding cell in Column C should contain the result of the multiplication of the number part of the cell in Column A with 5. If the cell in Column A contains 'b', the corresponding cell in Column C should contain the result of the multiplication of the number part of the cell in Column A with 2. If the cell in Column A contains no alphabets (i.e. it is a number), copy the number to the corresponding cell in Column C.
I think the solution will involve the use of "contains" to search for 'c' or 'b'. Perhaps an If Statement? I am not sure. I certainly need help extracting the number part of the cell in Column A and populating the correct value in Column C. I am fairly new to Python.
Thank you for your help.

A:

This should work:
def parse_data(x):
    if 'c' in x:
        num = int(x.split('c')[0])
        return num * 5
    elif 'b' in x:
        num = int(x.split('b')[0])
        return num * 2
    else:
        return x

df['C'] = df['A'].apply(lambda x: parse_data(x))

     A      B   C
0   3c  Prod1  15
1  20b  Prod2  40
2    9  Prod3   9

