python is bugging

Dave Martin dschwartz0705 at gmail.com
Sat Sep 21 13:08:05 EDT 2019


On Saturday, September 21, 2019 at 12:44:27 PM UTC-4, Brian Oney wrote:
> On Sat, 2019-09-21 at 08:57 -0700, Dave Martin wrote:
> > On Saturday, September 21, 2019 at 11:55:29 AM UTC-4, Dave Martin
> > wrote:
> > > what does expected an indented block
> > 
> > *what does an indented block mean?
> 
> It means that the line of code belongs to a certain body as defined
> above its position.  
> 
> Please follow the tutorial.
> 
> https://docs.python.org/3/tutorial/index.html

df.to_csv(r"faststars.csv", index=None,header=True)
# 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')

this is my code the error is on line 15



More information about the Python-list mailing list