[FEA] cuDF doesn't work out of the box with `NamedTuple` when constructing a `DataFrame`
- Dominant language
- C++
- Stars
- 9.8k
- Forks
- 1.1k
- Avg merge
- 3d 6m
- Merged PRs (30d)
- 278
Description
**Is your feature request related to a problem? Please describe.**
cuDF doesn't work out of the box with `NamedTuple` when constructing a `DataFrame`
**Describe the solution you'd like**
Add support for `NamedTuple`
**Describe alternatives you've considered**
First, create a `NamedTuple` object:
```python
from typing import NamedTuple, Optional, List
class ModelPrediction(NamedTuple):
suspicious: Optional[bool]
confidence: Optional[float]
prediction: Optional[List[float]]
outputs = [ModelPrediction(suspicious=True, confidence=0.1, prediction=60), ModelPrediction(suspicious=False, confidence=0.6, prediction=40), ModelPrediction(suspicious=True, confidence=0.8, prediction=30)]
```
cuDF workaround:
```python
import cudf as pd
pd.DataFrame(list(iter(outputs)), columns=ModelPrediction.__annotations__.keys())
```
**Additional context**
Pandas works out of the box:
```python
import pandas as pd
pd.DataFrame(iter(outputs))
```
while cuDF produces a DataFrame with column names missing:
```python
import cudf as pd
pd.DataFrame(list(iter(outputs))) # column names missing
```
Output:
```
suspicious confidence prediction
0 True 0.1 60
1 False 0.6 40
2 True 0.8 30
```
Contributor guide
Assessment
This issue has not been assessed yet.