Re: python is bugging

2019-09-21 Thread Piet van Oostrum
Dave Martin  writes:

> 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

1) What is line 15?
2) Always copy/paste the complete error message with your question.
3) Your with body is not indented:

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)

But how should WE know how many lines belong to the body of the with statements?
You should know that and indicate that with the indentation as described in the 
tutorial.

And then there's also a strange line:
c="radial_velocity", colormap="plasma")

Probably meant to be a continuation of the previous, commented line, but as 
written it isn't.
-- 
Piet van Oostrum 
WWW: http://piet.vanoostrum.org/
PGP key: [8DAE142BE17999C4]
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: python is bugging

2019-09-21 Thread Piet van Oostrum
Dave Martin  writes:

> 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?

From the tutorial, https://docs.python.org/3/tutorial/

3.2. First Steps Towards Programming:

The body of the loop is indented: indentation is Python’s way of grouping 
statements. At the interactive prompt, you have to type a tab or space(s) for 
each indented line. In practice you will prepare more complicated input for 
Python with a text editor; all decent text editors have an auto-indent 
facility. When a compound statement is entered interactively, it must be 
followed by a blank line to indicate completion (since the parser cannot guess 
when you have typed the last line). Note that each line within a basic block 
must be indented by the same amount.

-- 
Piet van Oostrum 
WWW: http://piet.vanoostrum.org/
PGP key: [8DAE142BE17999C4]
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: python is bugging

2019-09-21 Thread DL Neil via Python-list

On 22/09/19 5:08 AM, Dave Martin wrote:

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.

...


this is my code the error is on line 15



Did you follow the tutorial?

Is it easy (for *volunteer* helpers) to work-out which is line 15?

Back to the original question: Is the (loop) code actually indented?

--
Regards =dn
--
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 Brian Oney via Python-list
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

-- 
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