OiO.lk Blog python How to create dataframe with nested List of varying elements in Polars?
python

How to create dataframe with nested List of varying elements in Polars?


I am trying to create a dataframe from nested list that has varying elements in it. Eventually I will unnest/explode this but stuck at first stage as of now.

Below is the sample data and code which is failing:

import polars as pl

pl.DataFrame({'title': ['a','b','x','y'],
              
              'info': [['Email','Contact','State','City','Wesbsite','Source'],
                       ['Email','Contact','State','City'],
                       ['Email','Contact','State','City','Wesbsite']
                       ['Email','Contact','State'] 
                        ]
            })

Even this is not working:

pl.DataFrame({
              'info': [['Email','Contact','State','City','Wesbsite','Source'],
                       ['Email','Contact','State','City'],
                       ['Email','Contact','State','City','Wesbsite']
                       ['Email','Contact','State'] 
                        ]
            })



You need to sign in to view this answers

Exit mobile version