Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Creating DataFrame from python list #16251

Open
2 tasks done
Vijendra07Kulhade opened this issue May 15, 2024 · 1 comment
Open
2 tasks done

Creating DataFrame from python list #16251

Vijendra07Kulhade opened this issue May 15, 2024 · 1 comment
Labels
bug Something isn't working needs triage Awaiting prioritization by a maintainer python Related to Python Polars

Comments

@Vijendra07Kulhade
Copy link

Checks

  • I have checked that this issue has not already been reported.
  • I have confirmed this bug exists on the latest version of Polars.

Reproducible example

import polars as pl
print(pl.__version__)

# Your 2D list
data = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]

# Create DataFrame with column names
df = pl.DataFrame(data, columns=["A", "B", "C"])

print(df)

Log output

0.20.2
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-5-4089a37271bc> in <cell line: 8>()
      6 
      7 # Create DataFrame with column names
----> 8 df = pl.DataFrame(data, columns=["A", "B", "C"])
      9 
     10 print(df)

TypeError: DataFrame.__init__() got an unexpected keyword argument 'columns'

Issue description

Unable to create DataFrame like Pandas.

Expected behavior

It should create dataframe like pandas.

Installed versions

Replace this line with the output of pl.show_versions(). Leave the backticks in place.

-------Version info---------
Polars: 0.20.2
Index type: UInt32
Platform: Linux-6.1.58+-x86_64-with-glibc2.35
Python: 3.10.12 (main, Nov 20 2023, 15:14:05) [GCC 11.4.0]

----Optional dependencies----
adbc_driver_manager: 0.11.0
cloudpickle: 2.2.1
connectorx: 0.3.3
deltalake: 0.17.4
fsspec: 2023.6.0
gevent: 24.2.1
matplotlib: 3.7.1
numpy: 1.25.2
openpyxl: 3.1.2
pandas: 2.0.3
pyarrow: 14.0.2
pydantic: 2.7.1
pyiceberg: 0.6.1
pyxlsb:
sqlalchemy: 2.0.30
xlsx2csv: 0.8.2
xlsxwriter: 3.2.0
None

TypeError Traceback (most recent call last)
in <cell line: 8>()
6
7 # Create DataFrame with column names
----> 8 df = pl.DataFrame(data, columns=["A", "B", "C"])
9
10 print(df)

TypeError: DataFrame.init() got an unexpected keyword argument 'columns'

@Vijendra07Kulhade Vijendra07Kulhade added bug Something isn't working needs triage Awaiting prioritization by a maintainer python Related to Python Polars labels May 15, 2024
@cmdlineluser
Copy link
Contributor

It's schema= in Polars.

>>> pl.DataFrame(data, schema=["A", "B", "C"])
shape: (3, 3)
┌─────┬─────┬─────┐
│ ABC   │
│ --------- │
│ i64i64i64 │
╞═════╪═════╪═════╡
│ 147   │
│ 258   │
│ 369   │
└─────┴─────┴─────┘

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs triage Awaiting prioritization by a maintainer python Related to Python Polars
Projects
None yet
Development

No branches or pull requests

2 participants