Re: Python shows error on line 15 that i cant fix

2019-09-21 Thread Dave Martin
On Saturday, September 21, 2019 at 2:46:15 PM UTC-4, boB Stepp wrote:
> On Sat, Sep 21, 2019 at 1:01 PM Dave Martin  wrote:
> >
> > On Saturday, September 21, 2019 at 1:33:12 PM UTC-4, Terry Reedy wrote:
> > > On 9/21/2019 11:53 AM, Dave Martin wrote:
> [...]
> > > > #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)
> > >
> > > A 'with' statement is a compound statement.  It must be followed by a
> > > 'suite', which usually consists of an indented block of statements.
> > > This is line 17 from the first non-blank line you posted.
> [...]
> 
> > Can you provide an example of how to use the suite feature. Thank you.
> 
> Dave, you seem to have some expectation that you should be given the
> answer.  That is not how help is given in this forum.  You are
> expected to be doing the needed to work before being helped further.
> You have been referred to the tutorial multiple times.  Please read
> it!  Indentation is so fundamental to structuring Python code that it
> is clear that you need grounding in Python fundamentals.  Otherwise
> you are essentially Easter-egging through a code sample that you have
> no true understanding of.
> 
> If you must continue to Easter-egg Python instead of reading the
> tutorial (or something equivalent) then check the section of the
> tutorial on files.  You will find examples of the use of "with" there.
> 
> 
> -- 
> boB
Bob,
You seem to have the expectation that you know more about coding than me and 
that you can insult me without me retaliating. If I were you, I would leave 
this forum and never respond to another person question again, if you think 
that you can rudely ransack your way through what is supposed to be a helpful 
tool.

-Dave
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python shows error on line 15 that i cant fix

2019-09-21 Thread Dave Martin
On Saturday, September 21, 2019 at 1:33:12 PM UTC-4, Terry Reedy wrote:
> On 9/21/2019 11:53 AM, Dave Martin wrote:
> > 
> > # 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)
> 
> A 'with' statement is a compound statement.  It must be followed by a 
> 'suite', which usually consists of an indented block of statements.
> This is line 17 from the first non-blank line you posted.
> 
> Please stop spamming the list with multiple posts.  Do spend a few hours 
> reading the tutorial until you understand my answer.
> https://docs.python.org/3/tutorial/index.html  Also read 
> https://stackoverflow.com/help/minimal-reproducible-example
> so you can ask better questions.
> 
> I presume you got "SyntaxError: expected an indented block".
> A minimal example getting this error is, for instance,
> 
> while True:
> a = 1
> 
> -- 
> Terry Jan Reedy

Can you provide an example of how to use the suite feature. Thank you. 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: python is bugging

2019-09-21 Thread Dave Martin
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
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: python is bugging

2019-09-21 Thread Dave Martin
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?
-- 
https://mail.python.org/mailman/listinfo/python-list


python is bugging

2019-09-21 Thread Dave Martin
what does expected an indented block
-- 
https://mail.python.org/mailman/listinfo/python-list


Python shows error on line 15 that i cant fix

2019-09-21 Thread Dave Martin


# 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')

-- 
https://mail.python.org/mailman/listinfo/python-list