1

Can Deedle be effectively used from IronPython? It might seem perverse to do so, but it looks like getting pandas to fully work from IronPython might be difficult - there are some inactive porting projects and methods using IronClad but its not clear if anyone has actually successfully done so. Using a pure .NET solution like Deedle seems like a better route.

btrask
  • 141
  • 1
  • 7

2 Answers2

0

Deedle is a standard .NET library. My knowledge of IronPython is somewhat limited, but I think it lets you work with .NET languages - and so it should work with Deedle too. The Deedle documentation has a number of examples showing how to use it from C#, so if you know how to use other .NET libraries from IronPython, you should be able to translate the C# examples to IronPython.

Tomas Petricek
  • 240,744
  • 19
  • 378
  • 553
0

My personal experience is that trying to make CPython libraries such as pandas to work on ironpython is a dead-end. Although there is a way to do it, it is very unstable and unreliable.

Deedle seems like the next obvious choice, and it works. You just need to add the reference to the assembly, and also be careful on how IronPython handle generic arguments.

import clr;
import random;
from System import Tuple;
import itertools;

clr.AddReferenceToFileAndPath ("C:\\temp\\testedeedle\\packages\\FSharp.Core\\lib\\net40\\FSharp.Core.dll")
clr.AddReferenceToFileAndPath ("C:\\temp\\testedeedle\\packages\\Deedle\\lib\\net40\\Deedle.dll")

from Deedle import *

So then you can create dataframes with the existing Api, such as:

myPythonList = [("ID1", 1.1, 1.2), 
                ("ID2", 1.1, 1.2),
                ("ID3", 1.1, 1.2),
                ("ID4", 1.1, 1.2)];

values = [[Tuple.Create[str,str,float](x[0], "FirstValue", x[1]), Tuple.Create(x[0], "SecondValue", x[2])] for x in myPythonList]
tupleList =list((itertools.chain(*values)))
frame = Frame.FromValues[str,str,float](tupleList);
FrameExtensions.Print(frame);
series_mult = frame.FirstValue + frame.SecondValue
print (series_mult)
frame2 = frame * 2
FrameExtensions.Print(frame2);

yields...

       FirstValue SecondValue 
ID1 -> 1.1        1.2         
ID2 -> 1.1        1.2         
ID3 -> 1.1        1.2         
ID4 -> 1.1        1.2         

series [ ID1 => 2.3; ID2 => 2.3; ID3 => 2.3; ID4 => 2.3]
       FirstValue SecondValue 
ID1 -> 2.2        2.4         
ID2 -> 2.2        2.4         
ID3 -> 2.2        2.4         
ID4 -> 2.2        2.4   
Community
  • 1
  • 1
Fabio Marreco
  • 2,186
  • 2
  • 23
  • 24