Skip to content

Commit

Permalink
Fix dtype that got lost when calling to_pandas(); from object to float
Browse files Browse the repository at this point in the history
  • Loading branch information
bsipocz committed Mar 8, 2025
1 parent 877d4e3 commit 812a8df
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions light_curves/code_src/gaia_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,12 @@ def gaia_clean_dataframe(gaia_df):
# and only keep those columns that we need for the MultiIndexDFObject
gaia_df = gaia_df[colmap.keys()].rename(columns=colmap)

# We need to flatted out the multidim columns. Also note, the dtype of these columns
# are not properly propagated when ``to_pandas()`` was called, we deal with this issue now.

gaia_df = gaia_df.explode(['flux', 'err', 'time'])
gaia_df = gaia_df.astype({'flux': float, 'err': float})

# return the light curves as a MultiIndexDFObject
indexes, columns = ["objectid", "label", "band", "time"], ["flux", "err"]
df_lc = MultiIndexDFObject(data=gaia_df.set_index(indexes)[columns])
Expand Down

0 comments on commit 812a8df

Please sign in to comment.