spedas / pyspedas

Python-based Space Physics Environment Data Analysis Software
https://pyspedas.readthedocs.io/
MIT License
147 stars 58 forks source link

pytplot gives multiple FutureWarning for store_data #766

Closed nickssl closed 6 months ago

nickssl commented 6 months ago

Loading some MAVEN data, gives multiple warnings like the following:

13-Feb-24 11:26:42:\PyTplot\pytplot\store_data.py:152: FutureWarning: Series.getitem treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use ser.iloc[pos] elif isinstance(times[0], int) or isinstance(times[0], np.integer):

This seems to be the following issue:

https://stackoverflow.com/questions/77106980/pandas-2-1-0-futurewarning-series-getitem-treating-keys-as-positions-is-dep

nickssl commented 6 months ago

Fixed.

Variable 'times' is sometimes a pandas series and sometimes a numpy array. The recommendation is to access pandas series using times.iloc[pos] but for the numpy array it is times[pos]. The solution is to change the pandas series to a numpy array, so we can always use times[pos].