Python SQL脚本未运行

时间:2015-10-13 21:06:03

标签: sql python-2.7 pandasql

有人可以告诉我这个Python代码中是否存在SQL语句问题或任何其他问题?我无法让脚本运行。

import pandas
import pandasql


def avg_weekend_temperature(filename):

    weather_data = 
    pandas.read_csv('c:/python27/data/weather_underground.csv')

    q = 'SELECT AVG(meantempi) FROM weather_data WHERE
               DATENAME(weekday,date)=Saturday OR 
               DATENAME(weekday,date)=Sunday';

    mean_weekend_temp = pandasql.sqldf(q.lower(), locals())
    print mean_weekend_temp
    return mean_weekend_temp

avg_weekend_temperature('c:/python27/data/weather_underground.csv')

0 个答案:

没有答案