dotnet / dotnet/machinelearning
[DataFrame] DataFrame operations "obj" return type
- Dominant language
- C#
- Stars
- 9.4k
- Forks
- 2k
- Avg merge
- 2d 20h
- Merged PRs (30d)
- 11
Description
Given a DataFrameColumn with data similar to the following:

Performing operations like `Sum` return values of type `obj`. This causes issues when trying to use it in other contexts / operations.
Example:
Suppose I want to manually calculate the sum of a numeric column and divide it by 3:
```fsharp
df.["PetalLength"].Sum() / 3
```
The code throws the following exception - **The type 'int' does not match the type 'obj'**
The first thought is to cast.
```fsharp
((float32)df.["PetalLength"].Sum())
```
This approache, throws exception - **typecheck error The type 'obj' does not support a conversion to the type 'float32**.
The two ways that actually work are the following:
Using the casting operator:
```fsharp
(df.["PetalLength"].Sum() :?> float32) / 3.f
```
or unboxing:
```fsharp
df.["PetalLength"].Sum() |> unbox
```
In a sense it's not really a bug, but the ability to provide the return type and avoid casting would make it cleaner / simpler on the user.
i.e. `df.[PetalLength].Sum()`
Contributor guide
Assessment
This issue has not been assessed yet.