title: How to Convert Pandas Data Frame Schema
body: <p>I am reading a CSV file with <code>pandas.read_csv</code> and it detects the schema automatically which is like</p>
  
  <pre><code>Column1: string
  Column2: string
  Column3: string
  Column4: int64
  Column5: double
  Column6: double
  __index_level_0__: int64
  </code></pre>
  
  <p>Then, I am trying to write it with <code>pyarrow.parquet.write_table</code>  as a Parquet table. However, I want to use the following schema for the new parquet file</p>
  
  <pre><code>Column1: string
  Column2: string
  Column3: string
  Column4: string
  Column5: string
  Column6: string
  __index_level_0__: int64
  </code></pre>
  
  <p>But I get an error saying "Table schema does not match schema used to create file". Here is the piece of code I have used to convert a CSV file to a Parquet file <a href="https://stackoverflow.com/questions/26124417/how-to-convert-a-csv-file-to-parquet">borrowed from here</a></p>
  
  <pre><code>import pandas as pd
  import pyarrow as pa
  import pyarrow.parquet as pq
  
  csv_file = 'C:/input.csv'
  parquet_file = 'C:/putput.parquet'
  chunksize = 100_000
  
  csv_stream = pd.read_csv(csv_file, sep=',', chunksize=chunksize, low_memory=False, encoding="ISO-8859-1")
  
  for i, chunk in enumerate(csv_stream):
      print("Chunk", i)
      if i == 0:
          # Guess the schema of the CSV file from the first chunk
          # parquet_schema = pa.Table.from_pandas(df=chunk).schema
          parquet_schema = pa.schema([
              ('c1', pa.string()),
              ('c2', pa.string()),
              ('c3', pa.string()),
              ('c4', pa.string()),
              ('c5', pa.string()),
              ('c6', pa.string())
          ])
          # Open a Parquet file for writing
          parquet_writer = pq.ParquetWriter(parquet_file, parquet_schema, compression='snappy')
      # Write CSV chunk to the parquet file
      table = pa.Table.from_pandas(chunk, schema=parquet_schema)
      parquet_writer.write_table(table)
  
  parquet_writer.close()
  </code></pre>