Uploaded image for project: 'Apache Arrow'
  1. Apache Arrow
  2. ARROW-7782

[Python] Losing index information when using write_to_dataset with partition_cols

Agile BoardAttach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • None
    • 1.0.0
    • Python
    • None
    • pyarrow==0.15.1
    • Important

    Description

      One cannot save the index when using pyarrow.parquet.write_to_dataset() with given partition_cols arguments. Here I have created a minimal example which shows the issue:

       
      from pathlib import Path
      import pandas as pd
      from pyarrow import Table
      from pyarrow.parquet import write_to_dataset, read_table
      
      path = Path('/home/user/trials')
      file_name = 'local_database.parquet'
      df = pd.DataFrame({"A": [1, 2, 3], "B": ['a', 'a', 'b']}, 
                        index=pd.Index(['a', 'b', 'c'], 
                        name='idx'))
      
      table = Table.from_pandas(df)
      write_to_dataset(table, 
                       str(path / file_name), 
                       partition_cols=['B']
                      )
      df_read = read_table(str(path / file_name))
      df_read.to_pandas()
      

       

      The issue is rather important for pandas and dask users.

      Attachments

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            jorisvandenbossche Joris Van den Bossche Assign to me
            LudwikB Ludwik Bielczynski
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment