Pythonnet System.Object[,] to a Pandas DataFrame or Numpy array

Pythonnet System.Object[,] to a Pandas DataFrame or Numpy array … here is a solution to the problem.

Pythonnet System.Object[,] to a Pandas DataFrame or Numpy array

I’m calling a C# function using Pythonnet that returns a clr object (an n x m matrix). In Python, the type is System.Object[,].
How do I convert this variable to a Pandas DataFrame or something more manageable?

Thank you.

Solution

pd. DataFrame([[obj[j, i] for j in range(obj. GetLength(1))] for i in range(obj. GetLength(0))])

Related Problems and Solutions