Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions leanframe/core/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,10 @@ def __init__(self, data):
else:
raise NotImplementedError("DataFrame constructor doesn't support local data yet.")

@property
def columns(self) -> pandas.Index:
"""The column labels of the DataFrame."""
return pandas.Index(self._data.columns, dtype="object")

def to_pandas(self) -> pandas.DataFrame:
return self._data.to_pandas()
5 changes: 5 additions & 0 deletions tests/unit/session/test_read_sql_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

import leanframe

import pandas.testing


def test_read_sql_table_can_convert_to_pandas(session: leanframe.Session):
"""Read a table with simple scalar values."""
Expand All @@ -26,3 +28,6 @@ def test_read_sql_table_can_convert_to_pandas(session: leanframe.Session):
# Make sure we have _some_ data.
assert len(df_pd.index) > 0
assert len(df_pd.columns) > 0

# Where possible, check that we are compatible with pandas.
pandas.testing.assert_index_equal(df_pd.columns, df_lf.columns)