Skip to content

Commit

Permalink
Fixed error that occurred when reading a fits file and converting it …
Browse files Browse the repository at this point in the history
…to pandas using tables_io and python in version 3.10.
  • Loading branch information
crisingulani committed May 21, 2024
1 parent 9ce9502 commit 2964e05
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pandas>=1.2.0
requests>=2.23.0
astropy>=5.0.0
matplotlib>=3.6.0
tables_io>=0.7.9
tables_io>=0.9.6
Jinja2>=3.1.2
ipython>=8.5.0
h5py>=3.8.0
Expand Down
4 changes: 2 additions & 2 deletions src/pzserver/catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"""

import matplotlib.pyplot as plt
import pandas as pd
from IPython.display import display


Expand All @@ -16,7 +15,8 @@ def __init__(self, data=None, metadata=None, metadata_df=None):
"""
Catalog class constructor
"""
self.data = pd.DataFrame(data)

self.data = data
self.metadata = metadata
self.columns = metadata.get("main_file").get("columns_association")
self.metadata_df = metadata_df
Expand Down
11 changes: 7 additions & 4 deletions src/pzserver/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -377,13 +377,16 @@ def get_product(self, product_id=None, fmt=None):
return dataframe
results = self.__transform_df(dataframe, metadata)
else:
dataframe = tables_io.read(file_path) # default types in Astropy Table

if fmt == "astropy":
return tables_io.read(file_path, tType=tables_io.types.AP_TABLE)
dataframe = tables_io.read(
file_path, tType=tables_io.types.PD_DATAFRAME
)
return dataframe

dataframe = dataframe.to_pandas()

if fmt == "pandas":
return dataframe

results = self.__transform_df(dataframe, metadata)

print("Done!")
Expand Down

0 comments on commit 2964e05

Please sign in to comment.