title: Pandas IOError: [Errno 13] Permission denied
body: <p>I've been trying to run pandas using python 2.7 on a macbook pro and keep getting the following error:</p>
  
  <p>File "/Users/Hofstadter/anaconda/lib/python2.7/site-packages/pandas/io/common.py", line 376, in _get_handle
      f = open(path_or_buf, mode)</p>
  
  <p>IOError: [Errno 13] Permission denied: 'datasets/cats_0.8_0.6_0.4_0.2/target.csv'</p>
  
  <p>It looks like for some reason the folder being created for the files below, including target.csv, has restricted permissions. Here's what that code looks like:</p>
  
  <pre><code>def get_tables(df):
      categorical_cols = [col for col in df.columns if col.endswith('_cat')]
      train_table = df[categorical_cols]
      for col in categorical_cols:
          train_table = pd.concat(
              [
                  train_table, pd.get_dummies(
                      train_table[col],
                      prefix=col,
                      prefix_sep='_',
                      dummy_na=False).astype(int)
              ],
              axis=1,
              join='inner')
          train_table.drop(col, axis=1, inplace=True)
  
      print('Tables Created :)')
      return train_table
  </code></pre>
  
  <p>The tables are created without issue but then I get a permission error when trying to save them as below.</p>
  
  <pre><code>def save_tables(data_path,
                  df,
                  top_quant,
                  mh_quant,
                  ml_quant,
                  low_quant,
                  train=True):
  
      df = categorize_features(df, top_quant, mh_quant, ml_quant, low_quant)
      X = get_tables(df)
  
      os.makedirs(data_path, True)
  
      x_path = '{}/tournament_table.csv'.format(data_path)
  
      if train:
          x_path = '{}/train_table.csv'.format(data_path)
          y = df['target'].to_frame()
          y.columns = ['target']
          y.to_csv('{}/target.csv'.format(data_path), index=False)
      else:
          ids = df['id'].to_frame()
          ids.columns = ['id']
          ids.to_csv('{}/ids.csv'.format(data_path), index=False)
  
      X.to_csv(x_path, index=False)
  </code></pre>