diff --git a/climada_petals/entity/exposures/openstreetmap/osm_dataloader.py b/climada_petals/entity/exposures/openstreetmap/osm_dataloader.py index 8237a73ae..3005d9fe6 100644 --- a/climada_petals/entity/exposures/openstreetmap/osm_dataloader.py +++ b/climada_petals/entity/exposures/openstreetmap/osm_dataloader.py @@ -26,7 +26,7 @@ import urllib.request import geopandas as gpd -import numpy as np +import pandas as pd from osgeo import ogr, gdal import overpy import shapely @@ -417,28 +417,29 @@ def retrieve_cis(self, ci_type): """ # features consisting in points and multipolygon results: if ci_type in ['healthcare','education','food']: - gdf = self.retrieve('points', DICT_CIS_OSM[ci_type]['osm_keys'], - DICT_CIS_OSM[ci_type]['osm_query']) - gdf = gdf.append( + gdf = pd.concat([ + self.retrieve('points', DICT_CIS_OSM[ci_type]['osm_keys'], + DICT_CIS_OSM[ci_type]['osm_query']), self.retrieve('multipolygons', DICT_CIS_OSM[ci_type]['osm_keys'], - DICT_CIS_OSM[ci_type]['osm_query'])) + DICT_CIS_OSM[ci_type]['osm_query']), + ]) # features consisting in multipolygon results: elif ci_type in ['air']: gdf = self.retrieve('multipolygons', DICT_CIS_OSM[ci_type]['osm_keys'], - DICT_CIS_OSM[ci_type]['osm_query']) + DICT_CIS_OSM[ci_type]['osm_query']) # features consisting in points, multipolygons and lines: elif ci_type in ['gas','oil','telecom','water','wastewater','power', 'rail','road']: - gdf = self.retrieve('points', DICT_CIS_OSM[ci_type]['osm_keys'], - DICT_CIS_OSM[ci_type]['osm_query']) - gdf = gdf.append( + gdf = pd.concat([ + self.retrieve('points', DICT_CIS_OSM[ci_type]['osm_keys'], + DICT_CIS_OSM[ci_type]['osm_query']), self.retrieve('multipolygons', DICT_CIS_OSM[ci_type]['osm_keys'], - DICT_CIS_OSM[ci_type]['osm_query'])) - gdf = gdf.append( + DICT_CIS_OSM[ci_type]['osm_query']), self.retrieve('lines', DICT_CIS_OSM[ci_type]['osm_keys'], - DICT_CIS_OSM[ci_type]['osm_query'])) + DICT_CIS_OSM[ci_type]['osm_query']), + ]) else: LOGGER.warning('feature not in DICT_CIS_OSM. Returning empty gdf') gdf = gpd.GeoDataFrame() diff --git a/climada_petals/entity/exposures/test/test_spamagrar_unit.py b/climada_petals/entity/exposures/test/test_spamagrar_unit.py index 3b778d686..6e7c7bd7a 100644 --- a/climada_petals/entity/exposures/test/test_spamagrar_unit.py +++ b/climada_petals/entity/exposures/test/test_spamagrar_unit.py @@ -108,7 +108,7 @@ def init_testdata(): @staticmethod def assert_pd_frame_equal(df1, df2, **kwds): """Assert that two dataframes are equal, ignoring ordering of columns""" - from pandas.util.testing import assert_frame_equal + from pandas.testing import assert_frame_equal return assert_frame_equal(df1.sort_index(axis=1), df2.sort_index(axis=1), check_names=True, **kwds) diff --git a/climada_petals/hazard/emulator/stats.py b/climada_petals/hazard/emulator/stats.py index e6aa089ba..9ffd02872 100644 --- a/climada_petals/hazard/emulator/stats.py +++ b/climada_petals/hazard/emulator/stats.py @@ -71,7 +71,7 @@ def seasonal_average(data, season): data = data[(data['year'] > year_min) & (data['year'] <= year_max)] data = data.reset_index(drop=True) data = data.groupby('year').mean().reset_index() - return data.drop('month', 1) + return data.drop('month', axis=1) def seasonal_statistics(events, season): diff --git a/climada_petals/hazard/low_flow.py b/climada_petals/hazard/low_flow.py index cd8b5eae9..ec686d7f3 100644 --- a/climada_petals/hazard/low_flow.py +++ b/climada_petals/hazard/low_flow.py @@ -27,10 +27,12 @@ import datetime as dt from pathlib import Path import cftime -import xarray as xr import geopandas as gpd import numpy as np import numba +import pandas as pd +import xarray as xr + from sklearn.cluster import DBSCAN from sklearn.neighbors import BallTree @@ -754,7 +756,7 @@ def data_preprocessing_percentile(percentile, yearrange, yearrange_ref, dataf = _xarray_to_geopandas(data_chunk) first_file = False else: - dataf = dataf.append(_xarray_to_geopandas(data_chunk)) + dataf = pd.concat([dataf, _xarray_to_geopandas(data_chunk)]) del data_chunk dataf = dataf.sort_values(['lat', 'lon', 'dtime'], ascending=[True, True, True]) return dataf.reset_index(drop=True), centroids diff --git a/climada_petals/hazard/wildfire.py b/climada_petals/hazard/wildfire.py index 79ec5a277..cca16d246 100644 --- a/climada_petals/hazard/wildfire.py +++ b/climada_petals/hazard/wildfire.py @@ -606,7 +606,7 @@ def _clean_firms_df(self, df_firms): df_firms_viirs = df_firms_viirs.drop(df_firms_viirs[ \ df_firms_viirs.confidence == 'l'].index) df_firms_viirs = df_firms_viirs.rename(columns={'bright_ti4':'brightness'}) - temp = temp.append(df_firms_viirs, sort=True) + temp = pd.concat([temp, df_firms_viirs], sort=True) temp = temp.drop(columns=['bright_ti4']) df_firms = temp