title: Why does writing a dataframe to a file and reading it back again change the behavior of array assignment?
body: <p>My task involves appending two dataframes of the same kind (representing different time periods) and applying a lambda function to modify a column on the appended dataframe. </p>
  
  <p>This works as expected when run normally, but fails if the appended dataframe is written to csv and read back again. </p>
  
  <p>Setup</p>
  
  <pre><code>import pandas as pd
  import os
  
  os.chdir('/path//to/directory')
  
  df = pd.read_csv('Data-May.csv')
  df2 = pd.read_csv('Data-TillApr.csv')
  
  def foo(item):
      return item.replace("0"*11,"")
  </code></pre>
  
  <p>Applying lambda function individually on each dataframe - works </p>
  
  <pre><code>df['material'] = df.apply(lambda x: foo(x['material']), axis=1) #Works
  df2['material'] = df2.apply(lambda x: foo(x['material']), axis=1) #Works 
  </code></pre>
  
  <p>Applying lambda function on the appended dataframe - works  </p>
  
  <pre><code>df = pd.read_csv('Data-May.csv')
  df2 = pd.read_csv('Data-TillApr.csv')
  df3 = df2.append(df) 
  df3['material'] = df3.apply(lambda x: foo(x['material']), axis=1) #Works
  </code></pre>
  
  <p>Applying lambda function on the dataframe df3 if saved and read back  - fails</p>
  
  <p>It works if a new column is created though. </p>
  
  <pre><code>df = pd.read_csv('Data-May.csv')
  df2 = pd.read_csv('Data-TillApr.csv')
  df3 = df2.append(df)
  df3.to_csv('Data-Appended.csv') #Writing to csv
  df4 = pd.read_csv('Data-Appended.csv') #Reading it into a dataframe
  
  
  df4['material'] = df4.apply(lambda x: foo(x['material']), axis=1) #Doesn't work
  
  df4['new'] = df4.apply(lambda x: foo(x['material']), axis=1) #Works
  </code></pre>
  
  <p>The dtype for df3['material'] and df4['material'] are of type o. </p>
  
  <p>Traceback output for the line that doesn't work: </p>
  
  <blockquote>
  <pre><code>Traceback (most recent call last):
  
    File "&lt;ipython-input-42-096f7e61633e&gt;", line 1, in &lt;module&gt;
      df4['material'] = df4.apply(lambda x: foo(x['material']), axis=1) #Doesn't work
  
    File "/home/ubuntu/anaconda3/lib/python3.6/site-packages/pandas/core/frame.py",
  </code></pre>
    
    <p>line 2331, in <strong>setitem</strong>
            self._set_item(key, value)</p>
  
  <pre><code>  File "/home/ubuntu/anaconda3/lib/python3.6/site-packages/pandas/core/frame.py",
  </code></pre>
    
    <p>line 2398, in _set_item
            NDFrame._set_item(self, key, value)</p>
  
  <pre><code>  File "/home/ubuntu/anaconda3/lib/python3.6/site-packages/pandas/core/generic.py",
  </code></pre>
    
    <p>line 1759, in _set_item
            self._data.set(key, value)</p>
  
  <pre><code>  File "/home/ubuntu/anaconda3/lib/python3.6/site-packages/pandas/core/internals.py",
  </code></pre>
    
    <p>line 3731, in set
            group=True):</p>
  
  <pre><code>  File "/home/ubuntu/anaconda3/lib/python3.6/site-packages/pandas/core/internals.py",
  </code></pre>
    
    <p>line 4684, in _get_blkno_placements
            for blkno, indexer in lib.get_blkno_indexers(blknos, group):</p>
  
  <pre><code>  File "pandas/_libs/lib.pyx", line 1488, in pandas._libs.lib.get_blkno_indexers
  
  ValueError: Buffer has wrong number of dimensions (expected 1, got 0)
  </code></pre>
  </blockquote>