Commit 6e3932b
### Rationale for this change
Currently this keyword works for string or large string:
```python
>>> table = pa.table({"col": pa.array(["a", "b", "a"], pa.string())})
>>> table.to_pandas(strings_to_categorical=True).dtypes
col category
dtype: object
>>> table = pa.table({"col": pa.array(["a", "b", "a"], pa.large_string())})
>>> table.to_pandas(strings_to_categorical=True).dtypes
col category
dtype: object
```
but not for string view:
```python
>>> table = pa.table({"col": pa.array(["a", "b", "a"], pa.string_view())})
>>> table.to_pandas(strings_to_categorical=True).dtypes
col object
dtype: object
```
For consistency we should make that keyword check for string view columns as well, I think
From https://github.com/apache/arrow/pull/44195/files#r1901831460
### Are these changes tested?
Yes
### Are there any user-facing changes?
Yes, when using the `strings_to_categorical=True` keyword and having a string_view type, this column will now be converted to a pandas Categorical
* GitHub Issue: #45175
Authored-by: Joris Van den Bossche <[email protected]>
Signed-off-by: Raúl Cumplido <[email protected]>
1 parent f41f590 commit 6e3932b
File tree
2 files changed
+32
-6
lines changed- python/pyarrow
- src/arrow/python
- tests
2 files changed
+32
-6
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2523 | 2523 | | |
2524 | 2524 | | |
2525 | 2525 | | |
2526 | | - | |
| 2526 | + | |
| 2527 | + | |
2527 | 2528 | | |
2528 | 2529 | | |
2529 | 2530 | | |
| |||
2557 | 2558 | | |
2558 | 2559 | | |
2559 | 2560 | | |
2560 | | - | |
| 2561 | + | |
| 2562 | + | |
2561 | 2563 | | |
2562 | 2564 | | |
2563 | 2565 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1836 | 1836 | | |
1837 | 1837 | | |
1838 | 1838 | | |
1839 | | - | |
| 1839 | + | |
| 1840 | + | |
| 1841 | + | |
| 1842 | + | |
1840 | 1843 | | |
1841 | 1844 | | |
1842 | | - | |
| 1845 | + | |
1843 | 1846 | | |
1844 | 1847 | | |
1845 | 1848 | | |
| |||
1851 | 1854 | | |
1852 | 1855 | | |
1853 | 1856 | | |
1854 | | - | |
| 1857 | + | |
| 1858 | + | |
| 1859 | + | |
| 1860 | + | |
| 1861 | + | |
| 1862 | + | |
| 1863 | + | |
| 1864 | + | |
| 1865 | + | |
| 1866 | + | |
| 1867 | + | |
| 1868 | + | |
| 1869 | + | |
1855 | 1870 | | |
1856 | 1871 | | |
1857 | | - | |
| 1872 | + | |
1858 | 1873 | | |
1859 | 1874 | | |
1860 | 1875 | | |
| |||
1866 | 1881 | | |
1867 | 1882 | | |
1868 | 1883 | | |
| 1884 | + | |
| 1885 | + | |
| 1886 | + | |
| 1887 | + | |
| 1888 | + | |
| 1889 | + | |
| 1890 | + | |
| 1891 | + | |
| 1892 | + | |
1869 | 1893 | | |
1870 | 1894 | | |
1871 | 1895 | | |
| |||
0 commit comments