8000 remove all instances of .ix (#328) · adarga-Polytech/pvlib-python@66c70ba · GitHub
[go: up one dir, main page]

Skip to content

Commit 66c70ba

Browse files
authored
remove all instances of .ix (pvlib#328)
* remove all instances of .ix * add note to whatsnew
1 parent f8423c9 commit 66c70ba

File tree

8 files changed

+206
-291
lines changed

8 files changed

+206
-291
lines changed

docs/sphinx/source/forecasts.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ problems.
142142
data = data.join(irrad_data, how='outer')
143143
144144
# keep only the final data
145-
data = data.ix[:, model.output_variables]
145+
data = data[model.output_variables]
146146
147147
print(data.head())
148148

docs/sphinx/source/timetimezones.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ print just a few of the rows and columns of the large dataframe.
286286
287287
tmy3_data.index.tz
288288
289-
tmy3_data.ix[0:3, ['GHI', 'DNI', 'AOD']]
289+
tmy3_data.loc[tmy3_data.index[0:3], ['GHI', 'DNI', 'AOD']]
290290
291291
The :py:func:`~pvlib.tmy.readtmy2` function also returns a DataFrame
292292
with a localized DatetimeIndex.
@@ -309,7 +309,7 @@ DataFrame's index since the index has been localized.
309309
tmy3_metadata['latitude'],
310310
tmy3_metadata['longitude'])
311311
312-
ax = solar_position.ix[0:24, ['apparent_zenith', 'apparent_elevation', 'azimuth']].plot()
312+
ax = solar_position.loc[solar_position.index[0:24], ['apparent_zenith', 'apparent_elevation', 'azimuth']].plot()
313313
314314
ax.legend(loc=1);
315315
ax.axhline(0, color='darkgray'); # add 0 deg line for sunrise/sunset
@@ -340,7 +340,7 @@ below? The solar position calculator will assume UTC time.
340340
tmy3_metadata['latitude'],
341341
tmy3_metadata['longitude'])
342342
343-
ax = solar_position_notz.ix[0:24, ['apparent_zenith', 'apparent_elevation', 'azimuth']].plot()
343+
ax = solar_position_notz.loc[solar_position_notz.index[0:24], ['apparent_zenith', 'apparent_elevation', 'azimuth']].plot()
344344
345345
ax.legend(loc=1);
346346
ax.axhline(0, color='darkgray'); # add 0 deg line for sunrise/sunset
@@ -365,7 +365,7 @@ UTC, and then convert it to the desired time zone.
365365
366366
solar_position_hack.index
367367
368-
ax = solar_position_hack.ix[0:24, ['apparent_zenith', 'apparent_elevation', 'azimuth']].plot()
368+
ax = solar_position_hack.loc[solar_position_hack.index[0:24], ['apparent_zenith', 'apparent_elevation', 'azimuth']].plot()
369369
370370
ax.legend(loc=1);
371371
ax.axhline(0, color='darkgray'); # add 0 deg line for sunrise/sunset

docs/sphinx/source/whatsnew/v0.4.5.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ Bug fixes
1212
* Added NREL Bird clear sky model. (:issue:`276`)
1313
* Added lower accuracy formulas for equation of time, declination, hour angle
1414
and solar zenith.
15+
* Remove all instances of .ix (:issue:`322`)
16+
1517

1618
Enhancements
1719
~~~~~~~~~~~~~

docs/tutorials/pvsystem.ipynb

Lines changed: 185 additions & 273 deletions
Large diffs are not rendered by default.

pvlib/forecast.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -704,7 +704,7 @@ def process_data(self, data, cloud_cover='total_clouds', **kwargs):
704704
data['wind_speed'] = self.uv_to_speed(data)
705705
irrads = self.cloud_cover_to_irradiance(data[cloud_cover], **kwargs)
706706
data = data.join(irrads, how='outer')
707-
return data.ix[:, self.output_variables]
707+
return data[self.output_variables]
708708

709709

710710
class HRRR_ESRL(ForecastModel):
@@ -790,7 +790,7 @@ def process_data(self, data, cloud_cover='total_clouds', **kwargs):
790790
data['wind_speed'] = self.gust_to_speed(data)
791791
irrads = self.cloud_cover_to_irradiance(data[cloud_cover], **kwargs)
792792
data = data.join(irrads, how='outer')
793-
return data.ix[:, self.output_variables]
793+
return data[self.output_variables]
794794

795795

796796
class NAM(ForecastModel):
@@ -871,7 +871,7 @@ def process_data(self, data, cloud_cover='total_clouds', **kwargs):
871871
data['wind_speed'] = self.gust_to_speed(data)
872872
irrads = self.cloud_cover_to_irradiance(data[cloud_cover], **kwargs)
873873
data = data.join(irrads, how='outer')
874-
return data.ix[:, self.output_variables]
874+
return data[self.output_variables]
875875

876876

877877
class HRRR(ForecastModel):
@@ -955,7 +955,7 @@ def process_data(self, data, cloud_cover='total_clouds', **kwargs):
955955
data['wind_speed'] = self.gust_to_speed(data)
956956
irrads = self.cloud_cover_to_irradiance(data[cloud_cover], **kwargs)
957957
data = data.join(irrads, how='outer')
958-
return data.ix[:, self.output_variables]
958+
return data[self.output_variables]
959959

960960

961961
class NDFD(ForecastModel):
@@ -1024,7 +1024,7 @@ def process_data(self, data, **kwargs):
10241024
data['temp_air'] = self.kelvin_to_celsius(data['temp_air'])
10251025
irrads = self.cloud_cover_to_irradiance(data[cloud_cover], **kwargs)
10261026
data = data.join(irrads, how='outer')
1027-
return data.ix[:, self.output_variables]
1027+
return data[self.output_variables]
10281028

10291029

10301030
class RAP(ForecastModel):
@@ -1109,4 +1109,4 @@ def process_data(self, data, cloud_cover='total_clouds', **kwargs):
11091109
data['wind_speed'] = self.gust_to_speed(data)
11101110
irrads = self.cloud_cover_to_irradiance(data[cloud_cover], **kwargs)
11111111
data = data.join(irrads, how='outer')
1112-
return data.ix[:, self.output_variables]
1112+
return data[self.output_variables]

pvlib/irradiance.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1059,9 +1059,10 @@ def perez(surface_tilt, surface_azimuth, dhi, dni, dni_extra,
10591059
mask = sky_diffuse == 0
10601060
if isinstance(sky_diffuse, pd.Series):
10611061
diffuse_components = pd.DataFrame(diffuse_components)
1062-
diffuse_components.ix[mask] = 0
1062+
diffuse_components.loc[mask] = 0
10631063
else:
1064-
diffuse_components = {k: np.where(mask, 0, v) for k, v in diffuse_components.items()}
1064+
diffuse_components = {k: np.where(mask, 0, v) for k, v in
1065+
diffuse_components.items()}
10651066

10661067
return sky_diffuse, diffuse_components
10671068

pvlib/test/test_clearsky.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -708,6 +708,6 @@ def test_bird():
708708
# XXX: testdata starts at 1am so noon is at index = 11
709709
np.allclose(
710710
[Eb3, Ebh3, Gh3, Dh3],
711-
testdata2.ix[11, ['Direct Beam', 'Direct Hz', 'Global Hz', 'Dif Hz']],
711+
testdata2[['Direct Beam', 'Direct Hz', 'Global Hz', 'Dif Hz']].iloc[11],
712712
rtol=1e-3)
713713
return pd.DataFrame({'Eb': Eb, 'Ebh': Ebh, 'Gh': Gh, 'Dh': Dh}, index=times)

pvlib/test/test_pvsystem.py

Li BA42 nes changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -521,16 +521,16 @@ def test_PVSystem_scale_voltage_current_power():
521521

522522
def test_sapm_celltemp():
523523
default = pvsystem.sapm_celltemp(900, 5, 20)
524-
assert_allclose(43.509, default.ix[0, 'temp_cell'], 3)
525-
assert_allclose(40.809, default.ix[0, 'temp_module'], 3)
524+
assert_allclose(43.509, default['temp_cell'], 3)
525+
assert_allclose(40.809, default['temp_module'], 3)
526526
assert_frame_equal(default, pvsystem.sapm_celltemp(900, 5, 20,
527527
[-3.47, -.0594, 3]))
528528

529529

530530
def test_sapm_celltemp_dict_like():
531531
default = pvsystem.sapm_celltemp(900, 5, 20)
532-
assert_allclose(43.509, default.ix[0, 'temp_cell'], 3)
533-
assert_allclose(40.809, default.ix[0, 'temp_module'], 3)
532+
assert_allclose(43.509, default['temp_cell'], 3)
533+
assert_allclose(40.809, default['temp_module'], 3)
534534
model = {'a':-3.47, 'b':-.0594, 'deltaT':3}
535535
assert_frame_equal(default, pvsystem.sapm_celltemp(900, 5, 20, model))
536536
model = pd.Series(model)

0 commit comments

Comments
 (0)
0