Как я могу исправить «синтаксическую ошибку» в Python с помощью ноутбука Jupyter? - PullRequest
0 голосов
/ 11 апреля 2019

Привет попытался исправить ошибку, но я не смог, и я не знаю, где я иду не так, может кто-нибудь, пожалуйста, помогите. ниже мой код

моей предыдущей ошибкой была ошибка отступа

import pandas as pd 
import numpy as np
import xgboost as xgb
import sklearn as s 
import matplotlib 
import tensorflow as tf 
from sklearn.linear_model import LogisticRegression
from sklearn.svm import SVC
from IPython.display import display 
df = pd.read_csv("C:/Users/patel/Desktop/tap.csv")
from IPython.display import display
X_all = df.drop(['FTR'],1)
y_all = df['FTR']

# Standardising the data.
from sklearn.preprocessing import scale

#Center to the mean and component wise scale to unit variance.
cols = [['FTHG','FTAG','HTHG','HTAG']]
for col in cols:
    X_all[col] = scale(X_all[col])
X_all.HM1 = X_all.HM1.astype('str')
X_all.HM2 = X_all.HM2.astype('str')
X_all.HM3 = X_all.HM3.astype('str')
X_all.AM1 = X_all.AM1.astype('str')
X_all.AM2 = X_all.AM2.astype('str')
X_all.AM3 = X_all.AM3.astype('str')
def preprocess_features(X):
    output = pd.DataFrame(index = X.index)
    for col, col_df in X.iteritems():
             if col_df.dtype == object:
                col_df = pd.get_dummies(col_df, prefix = col)
    output = output.join(col_df)
    return output
X_all = preprocess_features(X_all)
print "Processed feature columns ({} total features):\n{}".format(len(X_all.columns), list(X_all.columns))
print "\nFeature values:"
display (X_all)

Файл "", строка 39 напечатать "Обработанные столбцы объектов ({} всего объектов): \ n {}". Формат (len (X_all.columns), список (X_all.columns)) ^ Ошибка синтаксиса: неверный синтаксис

1 Ответ

1 голос
/ 11 апреля 2019

Если вы используете Python 3, то скобки в функции print отсутствуют. Следующий код должен работать.

print("Processed feature columns ({} total features):\n{}".format(len(X_all.columns), list(X_all.columns)))
...