Python shows error on line 15 that i cant fix

Dave Martin dschwartz0705 at gmail.com
Sat Sep 21 11:53:00 EDT 2019


# starAbsMags=df['radial_velocity']

#GaiaPandasEscapeVelocityCode

import pandas as pd
import numpy as np
from astropy.io import fits
import astropy
import matplotlib.pyplot as plt


#get the combined data and load the fits files

fits_filename="Gaia_DR2/gaiadr2_100pc.fits"
df=pd.DataFrame()
with fits.open(fits_filename) as data:
df=pd.DataFrame(data[1].data)
df.columns=[c.lower() for c in df.columns]
print("Columns.")
print(df.columns.values)
print("n/n")
#print out some data meta info to see what we're working with
print("Number of stars:")
nstars=len(df)
print(nstars)
distances = (df['parallax']/1000)
starAbsMags =df['phot_g_mean_mag']
df = df[(df.parallax_over_error > 10 ) ]
print("Left after filter: " +str(len(df)/float(nstars)*100)+" %")
df.hist(column='radial_velocity')
#fastdf=df[(df.radial_velocity > 200) | (df.radial_velocity < -200)]
fastdf=df[(df.radial_velocity > 550)|(df.radial_velocity<-550)]
print(len(fastdf))
#print(fastdf)# starTemps=df['astrometric_weight_al']
# df.plot.scatter("radial_velocity", "astrometric_weight_al", s=1, c="radial_velocity", colormap="plasma")
# #df=df[(df.radial_velocity>=-550)]
# #plt.axis([0,400,-800,-550])
# #plt.axis([0,400,550,800])
# plt.xlabel('weight(Au)')
# plt.ylabel('Speed')
# plt.title('Gaia Speed vs Weight')




More information about the Python-list mailing list