Apache Arrow (C++)
A columnar in-memory analytics layer designed to accelerate big data.
arrow_to_pandas.h
Go to the documentation of this file.
1 // Licensed to the Apache Software Foundation (ASF) under one
2 // or more contributor license agreements. See the NOTICE file
3 // distributed with this work for additional information
4 // regarding copyright ownership. The ASF licenses this file
5 // to you under the Apache License, Version 2.0 (the
6 // "License"); you may not use this file except in compliance
7 // with the License. You may obtain a copy of the License at
8 //
9 // http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing,
12 // software distributed under the License is distributed on an
13 // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 // KIND, either express or implied. See the License for the
15 // specific language governing permissions and limitations
16 // under the License.
17 
18 // Functions for converting between pandas's NumPy-based data representation
19 // and Arrow data structures
20 
21 #ifndef ARROW_PYTHON_ADAPTERS_PANDAS_H
22 #define ARROW_PYTHON_ADAPTERS_PANDAS_H
23 
24 #include "arrow/python/platform.h"
25 
26 #include <memory>
27 #include <string>
28 
29 #include "arrow/util/visibility.h"
30 
31 namespace arrow {
32 
33 class Array;
34 class Column;
35 class DataType;
36 class MemoryPool;
37 class Status;
38 class Table;
39 
40 namespace py {
41 
42 struct PandasOptions {
44 };
45 
46 ARROW_EXPORT
47 Status ConvertArrayToPandas(PandasOptions options, const std::shared_ptr<Array>& arr,
48  PyObject* py_ref, PyObject** out);
49 
50 ARROW_EXPORT
51 Status ConvertColumnToPandas(PandasOptions options, const std::shared_ptr<Column>& col,
52  PyObject* py_ref, PyObject** out);
53 
54 // Convert a whole table as efficiently as possible to a pandas.DataFrame.
55 //
56 // The returned Python object is a list of tuples consisting of the exact 2D
57 // BlockManager structure of the pandas.DataFrame used as of pandas 0.19.x.
58 //
59 // tuple item: (indices: ndarray[int32], block: ndarray[TYPE, ndim=2])
60 ARROW_EXPORT
61 Status ConvertTableToPandas(PandasOptions options, const std::shared_ptr<Table>& table,
62  int nthreads, MemoryPool* pool, PyObject** out);
63 
64 } // namespace py
65 } // namespace arrow
66 
67 #endif // ARROW_PYTHON_ADAPTERS_PANDAS_H
Definition: status.h:106
Definition: arrow_to_pandas.h:42
Status ConvertColumnToPandas(PandasOptions options, const std::shared_ptr< Column > &col, PyObject *py_ref, PyObject **out)
bool strings_to_categorical
Definition: arrow_to_pandas.h:43
Top-level namespace for Apache Arrow C++ API.
Definition: allocator.h:29
Status ConvertArrayToPandas(PandasOptions options, const std::shared_ptr< Array > &arr, PyObject *py_ref, PyObject **out)
Base class for memory allocation.
Definition: memory_pool.h:34
Status ConvertTableToPandas(PandasOptions options, const std::shared_ptr< Table > &table, int nthreads, MemoryPool *pool, PyObject **out)