-
-
Notifications
You must be signed in to change notification settings - Fork 36
Open
Description
How could the content be improved?
In #74, the function that makes a pandas dataframe from an astropy table was updated to modify the input astropy table (adding some columns). In general, it's probably not a good idea to modify an input to a function unless the function is specifically designed to modify its input in place. However, I understand the change was made to resolve some errors in a pandas version update.
It seems that using .value when adding a skycoord sequence to pandas works now, e.g., df['phi1'] = skycoord_gd1.phi1.value:
def make_dataframe(table):
"""Transform and astropy table with coords in ICRS, convert to pandas dataframe with GD-1 coordinates."""
skycoord = SkyCoord(
ra=table['ra'],
dec=table['dec'],
pm_ra_cosdec=table['pmra'],
pm_dec=table['pmdec'],
distance=8*u.kpc,
radial_velocity=0*u.km/u.s)
# Transform to GD-1 frame
gd1_frame = GD1Koposov10()
transformed = skycoord.transform_to(gd1_frame)
skycoord_gd1 = reflex_correct(transformed)
df = table.to_pandas()
df['phi1'] = skycoord_gd1.phi1.value
df['phi2'] = skycoord_gd1.phi2.value
df['pm_phi1'] = skycoord_gd1.pm_phi1_cosphi2.value
df['pm_phi2'] = skycoord_gd1.pm_phi2.value
return dfWhich part of the content does your suggestion apply to?
https://datacarpentry.github.io/astronomy-python/03-transform.html#pandas-dataframe
Metadata
Metadata
Assignees
Labels
No labels