SyntaxError: invalid syntax Python 3.5 when trying to print in python, even with a simple print("Hello World") -
i finished deleting bunch of files off desktop , other misc. folders. re-opened project have been working on , won't print, simple 'hello world' line 144.
i have opened new python project , printed("hello world") , works fine, tried coping code same sheet , saving different name , same error.
this code using below; print way @ bottom.
from pandas_datareader import data dreader import pandas pd datetime import datetime import dateutil.parser tkinter import * # sets max rows can displayed # when program executed pd.options.display.max_rows = 200 # df name of dataframe, # reading csv file containing data loaded # yahoo finance(date,open,high,low,close # volume,adj close,)the name of ticker # placed before _data.csv i.e. ticker aapl # have csv file named aapl_data.csv. df = pd.read_csv("cde_data.csv") # resets index pandas default # i.e. index starts @ 0 first row , # 1 second , continues 1 till # end of data in above csv file. df.reset_index() # following code allow filtering of datafram # based on year, day of week (dow), , month. gets # applied dataframe , can used sort data i.e # print(df[(df.year == 2015) & (df.month == 5) & (df.dow == 4)]) # give days in month of may(df.month == 5), # fall on thursday(df.dow == 4), in year 2015 # (df.year == 2015) # # month dow year # january = 1 monday = 1 year dispaly in 4 # february = 2 tuesday = 2 digit format i.e. 2015 # march = 3 wednesday = 3 # april = 4 thursday = 4 # may = 5 friday = 5 # june = 6 # july = 7 # august = 8 # september = 9 # october = 10 # november = 11 # december = 12 def year(x): return(x.year) def dow(x): return(x.isoweekday()) def month(x): return(x.month) df.date = df.date.apply(dateutil.parser.parse) df['year'] = df.date.apply(year) df['dow'] = df.date.apply(dow) df['month'] = df.date.apply(month) # code below has total of 5 sections labeled number. # #1, #2, #3, #4, #5. number 1 adds new columns df # , populates them data, number 2 filters out days # market went down or flat day, number 3 filters # out of days market went or flat, number 4 # filters of days market went or down, , # number 5 drops excess columns , concats steps #2, #3, & #4. # 1 # there 5 columns being added, up_down, up, down, # flat, , %chg. up, down, , flat temporary , # deleted later on other 2 up_down, , %chg permeant. # up_down column derived taking 'close' column minus # 'open'column, tells how stock has moved day. # 'up' column temporary , has value of 'up' rows # of dataframe df. 'down' column temporary , has value of # 'down' rows of dataframe df. 'down' column # temporary , has value of 'flat' rows of dataframe # df. '%chg' column calculated taking results of # 'up_down' divided 'close' column, , times 100, # turns percentage show percent stock moved or # down day. of columns added below added # dataframe called df, contains a csv file(see code lines 14-20 # information on csv file contained in dataframe df). df['up_down'] = df['close'] - df['open'] df['up'] = 'up' df['down'] = 'down' df['flat'] = 'flat' df['%chg'] = ((df['up_down']/df['close'])*100) # 2 # df column[up_down] first filtered on greater 0 # criteria year 1984 on , turned df2. # if up_down column greater 0 means # stock went up. next df3 set = df2['up'], df3 holds # days asset went df2= (df[(df.year > 1984) & (df.up_down > 0)]) df3 = df2['up'] # 3 # df column[up_down] first filtered on less 0 # criteria year 1984 on , turned df4. # if up_down column less 0 means # stock went down. next df5 set = df4['down'], df5 holds # days asset went down df4= (df[(df.year > 1984) & (df.up_down < 0)]) df5 = df4['down'] # 4 # df column[up_down] first filtered on equal 0 # criteria year 1984 on , turned df6. # if up_down column equal 0 means # stock did not move. next df7 set = df6['flat'],df5 # holds days asset did not move @ df6= (df[(df.year > 1984) & (df.up_down == 0)]) df7 = df6['flat'] # 5 # code below starts droping columns 'up', 'down', , 'flat'. # these temporary , used filter data in above # code in sections two, three, , four. concat # dataframes df, df3, df5, , df7. have new 'up', 'down' , # 'flat' columns display up, down, or flat when criteria # true. df = df.drop(['up'], axis = 1) df = df.drop(['down'], axis = 1) df = df.drop(['flat'], axis = 1) df = pd.concat([df,df3,df5,df7],axis =1, join_axes=[df.index]) df['openchgprevday'] = ((df['open']-1)-(df['open']) print("hello world")
this error message
file "columnadder.py", line 144 print("hello world") ^ syntaxerror: invalid syntax press key continue . . .
there parenthesis here
df['openchgprevday'] = ((df['open']-1)-(df['open']) print("hello world")
to correct that, do
df['openchgprevday'] = (df['open']-1)-(df['open']) print("hello world")
Comments
Post a Comment