Common pip packages on the python CDK

Is it possible to develop canisters that are able to use pandas dataframes that have the values fetched through some API and make some computations with the dataframe values (even though the canister public shared functions does not return or receives dataframes as arguments) ?

General Simple Example
Fetch financial data with yfinance package and perform some operations on a query function that returns a float.

Pinging @lastmjs for this

1 Like

Using Kybra just try them out. Only pude Python packages will work and only those that don’t use unsupported APIs. We don’t have a comprehensive list of these.

So the best thing to do is just get it.

I tried compiling the code with a simple hello world python canister and it failed to compile numpy. I guess kybra cannot compile C based python packages (at least not yet). Either way, thanks you guys for the support.

2 Likes

Correct, no C extension support yet. I’m hoping sometime in 2025 this will be possible as CPython’s Wasi support may include the Wasm component model by that time.

1 Like

Unfortunately, a lot of alternatives to Pandas such as Vaex and Polars are not compatible due to their dependencies.

There are very lightweight pure Python pandas-like implementations out there that are quite old but might be able to do the job. For example, pambdas is a dependency-free pure Python dataframe.

Here is an example: GitHub - jennifertrin/kybra-dataframes: Example of using pambdas dataframes on Kybra on ICP.

You can certainly update the code to fetch data using HTTPS Outcalls, do some computation, and return a float.

How much data are you looking at? I am suggesting that do you need a dataframe?

Please let me know what you end up doing.

1 Like