我正在尝试使用Pysolar和Pandas来计算太阳方位角。我想计算DataFrame索引的方位角(如下面的代码所示)。但是当使用i< 2时,结果对于所有日期和时间是相同的方位角,然后第二次(i == 1)它是不同的但是对于所有日期和时间都相同。我只想将每个日期和时间的方位角计算为单独的列。对我做错了什么的想法?
>> import pandas as pd
>> import numpy as np
>> from pysolar.solar import *
>> importdatetime
>> X=pd.read_csv('/home/optim7/Dropbox/Smart_Analytics_work/WeatherData_WOOPA/PV_data/Testing123.csv',index_col='Datetime')
>> X.index = pd.to_datetime(X.index,unit='s')
>> X.head()
A
Datetime
2014-08-01 00:00:00 0
2014-08-01 00:15:00 0
2014-08-01 00:30:00 0
2014-08-01 00:45:00 0
2014-08-01 01:00:00 0
>> i = 0
>> while i < 2:
>> X['Azimuth']= get_azimuth(42.206,-71.382,X.index[i])
>> print (X)
>> i+=1
输出
A Azimuth
Datetime
2014-08-01 00:00:00 0 -107.280839
2014-08-01 00:15:00 0 -107.280839
2014-08-01 00:30:00 0 -107.280839
...
[42570 rows x 2 columns]
A Azimuth
Datetime
2014-08-01 00:00:00 0 -107.280839
2014-08-01 00:15:00 0 -107.280839
2014-08-01 00:30:00 0 -107.280839
...
[42570 rows x 2 columns]