Pandas Apply function not working consistently (Python 3)
<h2>Summary</h2>

<p>Procedure:
I have three functions. Function A, B, and C. Function A uses apply() to apply function B and C to a global Pandas DataFrame. </p>

<p>Problem:
Inspecting the results shows that only Function B was applied to the global dataframe</p>

<p>Other notes: 
If I apply Function C from the python interpreter, then it works. </p>

<hr>

<h2>The long version</h2>

<p>The three main functions in this problem are:</p>

<p>load_paypal(): Loads data into a gobal Pandas DataFrame and applies the other two functions on a couple columns.</p>

<p>read_cash(): reads in the value, strips dollar signs, commas etc and returns a number</p>

<p>read_date(): reads a string and returns a datetime.</p>

<p>The problem I'm having is that when I use apply() to apply read_cash, it appears to work but read_date doesn't. Additionally, when I use the read_date function with apply from the python interpreter, with the exact same code, I get the expected results, ie it works.</p>

<h2>Functions</h2>

<p>load_paypal</p>

<pre><code>def load_paypal():
    global paypal_data
    paypal_data = pd.DataFrame( pd.read_csv(open("Download.csv") ) )
    paypal_data = paypal_data.fillna(0)
    cash_names = ('Gross', 'Fee', 'Net', 'Shipping and Handling Amount', 'Sales Tax', 'Balance')

    for names in cash_names:
        paypal_data[names].apply( ryan_tools.read_cash )

    paypal_data = paypal_data.rename(columns = { paypal_data.columns[0] : 'Date'})

    paypal_data['Date'].apply( ryan_tools.read_date )
    print( paypal_data['Date'] ) # The 'Date' datatype is still a string here
    print( paypal_data['Net'] ) # The 'Net' datatype is proven to be converted
    # to a number over here( It definitely starts out as a string )
    return
</code></pre>

<p>ryan_tools.read_date</p>

<pre><code>def read_date(text):
    for fmt in ( '%m/%d/%y' , '%M/%D/%y' , '%m/%d/%Y', '%Y/%m/%d', '%Y/%M/%D', 'Report Date :%m/%d/%Y', '%Y%M%D' , '%Y%m%d' ):
        try:
            return datetime.datetime.strptime(text, fmt)
        except ValueError:
            pass
    raise ValueError('No Valid Date found')
</code></pre>

<p>ryan_tools.read_cash</p>

<pre><code>def read_cash(text):
    text = str(text)
    if text == '':
        return 0
    temp = text.replace(' ', '')
    temp = text.replace(',', '')
    temp = temp.replace('$', '')

    if ('(' in temp or ')' in temp):
        temp = temp.replace('(', '')
        temp = temp.replace(')', '')
        ans = float(temp) * -1.0
        return ans
    ans = round(float(temp),2)

    return ans
</code></pre>

<p>Notes: ryan_tools is just my general file of commonly used useful functions</p>