1

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

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')
4

0 回答 0