Search code examples
pythonpython-3.xjupyter-notebookdata-science

I got syntax error by using jupyter notebook


[Here the image] 1I dont know why i get this error. Here is the code:

import pandas as pd
import matplotlib.pyplot as plt 
import numpy as np 

data = pd.read_csv("files/ch04/ACCIDENTS_GU_BCN_2013.csv" , encoding= 'unicode_escape')
data['Date'] = data[u'Dia de mes']. apply(lambda x: str(x))
+ '-' + data[u'Mes de any']. apply(lambda x: str(x))
data['Date'] = pd.to_datetime(data['Date'])
accidents = data.groupby (['Date']).size()
print accidents.mean()

Solution

  • the problem here is that you're using Python3 which requires brackets after the print statement. So, do this : print(accidents.mean())