我正在尝试编译项目时出现关键错误。我想要做的是将所有这些位置设置为dfs。我查了python的例子,但我不知道我在这里做什么和他们在做什么有什么不同。错误发生在dfs [location] = newDF。
任何指导都非常感谢。谢谢!
import numpy as np
import pandas as pd
from datetime import datetime
df = pd.read_csv('Data.csv')
locations = set(df['NAME'])
dfs = { "ADA 0.7 SE, MI US", "ADA 1.8 W, MI US", "ALLENDALE 1.3 SSW, MI US",
"ALLENDALE 2.1 SE, MI US", "ALTO 4.5 SW, MI US", "BELMONT 1.0 WNW, MI US",
"CALEDONIA 4.4 WNW, MI US", "COMSTOCK PARK 1.0 NNW, MI US", "COMSTOCK PARK 3.7 NNE, MI US",
"CUTLERVILLE 1.0 NNE, MI US", "EAST GRAND RAPIDS, MI US", "GRAND RAPIDS 2.5 ENE, MI US", "GRAND RAPIDS 2.9 NW, MI US",
"GRAND RAPIDS 3.1 NNE, MI US", "GRAND RAPIDS 3.2 S, MI US", "GRAND RAPIDS 3.8 SE, MI US", "GRAND RAPIDS 4.6 ESE, MI US", "GRAND RAPIDS 5.5 SSE, MI US",
"GRAND RAPIDS 9.6 ESE, MI US", "GRAND RAPIDS GERALD R FORD INTERNATIONAL AIRPORT, MI US", "GRAND RAPIDS SUTRON, MI US", "GRANDVILLE 1.3 WSW, MI US",
"JENISON 1.0 NE, MI US", "KENTWOOD 1.6 WSW, MI US", "KENTWOOD 1.8 SSE, MI US", "NWSFO GRAND RAPIDS, MI US", "ROCKFORD 0.9 NNE, MI US", "ROCKFORD 5.0 ESE, MI US",
"ROCKFORD, MI US", "SPARTA 2.8 W, MI US", "WYOMING 0.5 NNE, MI US", "WYOMING 2.2 SW, MI US"}
for location in locations:
newDF = np.where(df['NAME'] == location)[0]
dfs[location] =newDF
df.to_csv("average2016.csv")