Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Built-in Support for TabularData Framework #20

Open
vojtamolda opened this issue Dec 9, 2021 · 0 comments
Open

Built-in Support for TabularData Framework #20

vojtamolda opened this issue Dec 9, 2021 · 0 comments
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed

Comments

@vojtamolda
Copy link
Owner

Apple recently published TabularData framework. Basically, it is a typed clone of Pandas from Python.

I'm a little disappointed that the framework isn't open sourced and available on Linux. I think it may hinder adoption, but hey that's life. There isn't much documentation or examples but there's a nice tech talk video that describes the API on a nice example.

It would be nice to add support for the DataFrame and Column types directly into the library. Best way to support the framework is add conformance to the Plotable protocol to a few types. This would allow out of the box dataset exploration and manipulation in Xcode Playgrounds.

Here's an example conformance extension and the generated figure:

import TabularData
import Plotly


let dataFrame: TabularData.DataFrame = [
    "id": [1, 2, 3],
    "name": ["alice", "bob", "charlie"]
]

let barPlot = Plotly.Bar(
    x: dataFrame[column: 1].assumingType(String.self),
    y: dataFrame[column: 0].assumingType(Int.self)
)

let figure = Plotly.Figure(data: [barPlot])
try figure.show()


extension TabularData.Column: Plotly.Plotable where WrappedElement: Encodable {
    public func encode(toPlotly encoder: Encoder) throws {
        var container = encoder.unkeyedContainer()
        for element in self {
            try container.encode(element)
        }
    }
}

Screen Shot 2021-12-08 at 23 21 23

@vojtamolda vojtamolda added enhancement New feature or request help wanted Extra attention is needed good first issue Good for newcomers labels Dec 9, 2021
@vojtamolda vojtamolda added this to the Ploly.swift 0.6.0 milestone Dec 9, 2021
@vojtamolda vojtamolda self-assigned this Dec 9, 2021
@vojtamolda vojtamolda removed their assignment Dec 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant