Reputation: 2139
I am trying to import a list of lists into Polars and get the data in seperate columns.
Example.
numbers = [['304-144635', 0], ['123-091523', 7], ['305-144931', 12], ['623-101523', 16], ['305-145001', 22], ['623-111523', 27], ['9998-2603', 29]]
Does not work like Pandas and this does not work.
df = pl.DataFrame(numbers)
new to polars and excited to start using. Thanks
Upvotes: 1
Views: 48
Reputation: 1398
You can do pl.DataFrame(numbers, orient="row")
if you are okay with the default column names Polars gives you (column_0, column_1). Or (as you show), you can specify the schema if you want to control the names of the columns or their types.
Also note that the default column names in Polars are different to those in pandas.
Upvotes: 1
Reputation: 2139
this seems to work is I add a schema? Maybe there is a more correct way?
df = pl.DataFrame(numbers, schema=['a', 'b'], orient="row")
Upvotes: 0