Using (+) Operator With Python Pandas Timestamp in F# Fable #73
Answered
by
jhonmolano09
jhonmolano09
asked this question in
Q&A
-
Below code works in python. import pandas
from pandas.tseries.offsets import BDay
result = pandas.Timestamp("2022-08-18") + BDay(1) And this is my F# Code type IPandas =
abstract member Timestamp: date:string -> obj
[<ImportAll("pandas")>]
let pandas: IPandas = nativeOnly
[<Import("BDay", from="pandas.tseries.offsets")>]
let BDay (days: int) :obj = nativeOnly
let result = pandas.Timestamp("2022-08-18") + BDay(1) // error: The type 'obj' does not support the operator '+'
But I get the error: The type 'obj' does not support the operator '+' |
Beta Was this translation helpful? Give feedback.
Answered by
jhonmolano09
Sep 19, 2022
Replies: 1 comment
-
So i ended using Emit and it works correctly [<Emit("$0 + $1")>]
let add (timestamp:obj) (bday:obj) :obj = nativeOnly
let start = pandas.Timestamp("2022-08-18")
let result = add start (BDay 1)
Compiles to valid python code start: Any = pandas.Timestamp("2022-08-18")
result: Any = start + BDay(int8(1.0)) |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
jhonmolano09
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
So i ended using Emit and it works correctly
Compiles to valid python code