forked from alfonsogarciacaro/fable-py-sample
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprogram.fsx
38 lines (28 loc) · 938 Bytes
/
program.fsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#r "nuget:Fable.Python"
open Fable.Core
open Fable.Core.PyInterop
open Fable.Python.Builtins
module Pandas =
type DataFrame =
[<Emit("$0[$1]")>]
abstract loc: label: obj -> 'T
type IPandas =
abstract read_csv: string -> DataFrame
[<ImportAll("pandas")>]
let pandas: IPandas = nativeOnly
open Pandas
[<EntryPoint>]
let main argv =
let name = Array.tryHead argv |> Option.defaultValue "Guest"
printfn $"Hello {name}!"
// Open file with builtin `open`
use file = builtins.``open``("data.txt", "r")
file.read() |> printfn "File contents: %s"
// Open file with Pandas. We don't have bindings yet
// but you can use dynamic programming
let df = pandas.read_csv("numbers.csv")
builtins.print(df)
let columnA: int[] = df.loc("A")
columnA |> Array.map (fun i -> i + 4) |> Array.sum |> printfn "%i"
// pandas?plotting?andrews_curves(df, "B")
0