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

[Python] Table.from_arrays should raise an error when array is empty but names is not

    XMLWordPrintableJSON

Details

    Description

      The `Table.from_arrays` method returns an empty schema when supplying an empty arrays list but providing column names. As a result, the subsequent `to_pandas` method returns an empty data frame with no column names.

      ```

      import pyarrow as pa

      arrays = []

      cols_names = ["col1", "col2"]

      table = pa.Table.from_arrays(arrays=arrays, names=cols_names)

      table.schema # returns nothing

      df = table.to_pandas()

      df.head()

      {{Empty DataFrame
      Columns: []
      Index: [] # Expected column names to be visible here}}

      ```

      I assume that this is because a schema cannot be built without data types?

      Attachments

        Issue Links

          Activity

            People

              alenkaf Alenka Frim
              jaidisido Abderrahmane Jaidi
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 2h 10m
                  2h 10m