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

Fix pandas column names; closes 39 #48

Merged
merged 1 commit into from
Jan 11, 2022
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
2 changes: 1 addition & 1 deletion astrodbkit2/astrodb.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ def _handle_format(temp, fmt):
else:
results = AstropyTable(temp)
elif fmt.lower() == 'pandas':
results = pd.DataFrame(temp)
results = pd.DataFrame(temp, columns=temp[0].keys())
else:
results = temp

Expand Down
5 changes: 5 additions & 0 deletions astrodbkit2/tests/test_astrodb.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,11 @@ def test_search_object(mock_simbad, db):
t = db.search_object('engu', fuzzy_search=False)
assert len(t) == 0

# Test pandas conversion
t = db.search_object('engu', fmt='pandas')
assert isinstance(t, pd.DataFrame)
assert 'source' in t.columns # check column names

# Search but only consider the Sources.source column
t = db.search_object('penguin', table_names={'Sources': ['source']})
assert len(t) == 0
Expand Down