Building DataFrames from objects
Sometimes, you’ll have a list of objects that you wish to get into a DataFrame
for further analysis. In this case, you can manually add data to an empty or existing DataFrame
.
While DataFrame
has a LoadFrom
method that can be used to load data, in practice, this method is a little cumbersome to work with when you’re trying to translate from a series of objects to rows and columns in a DataFrame
.
Instead, I’ll share a small proof of concept using .NET’s reflection capabilities.
Reflection
.NET’s reflection feature allows you to enumerate the methods and properties of different types within your assemblies, as well as perform more advanced operations in defining new types. Reflection is relatively slow and complex compared to other code, but it is a great way of allowing code to enumerate the different capabilities offered by other pieces of code.
In order to add data to a DataFrame
, we need to know the...