Skip to content

Commit 11e2c44

Browse files
authored
Fix concatenation of datasets when some are empty (#123)
1 parent 3449e7e commit 11e2c44

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

docs/release_notes.rst

+6
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ Release notes
44
Change log
55
----------
66

7+
Changes from 0.12.2 to 0.12.3
8+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
9+
10+
- Added support for Swarm FAST TEC ``SW_FAST_TECxTMS_2F`` products.
11+
- Fixed error when loading some chunked data with xarray, when one of the chunks has zero length
12+
713
Changes from 0.12.1 to 0.12.2
814
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
915

src/viresclient/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,4 @@
3535
from ._config import ClientConfig, set_token
3636
from ._data_handling import ReturnedData, ReturnedDataFile
3737

38-
__version__ = "0.12.2"
38+
__version__ = "0.12.3"

src/viresclient/_data_handling.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -783,7 +783,11 @@ def as_dataframe(self, expand=False):
783783
pandas.DataFrame
784784
785785
"""
786-
return pandas.concat([d.as_dataframe(expand=expand) for d in self.contents])
786+
dataframes = [data.as_dataframe(expand=expand) for data in self.contents]
787+
if len(dataframes) > 1:
788+
return pandas.concat([df for df in dataframes if not df.empty])
789+
else:
790+
return dataframes[0]
787791

788792
def as_xarray(self, reshape=False):
789793
"""Convert the data to an xarray Dataset.
@@ -821,6 +825,8 @@ def as_xarray(self, reshape=False):
821825
elif self._time_variable in ds_list[0].dims:
822826
# Address simpler concatenation case for VirES for Swarm
823827
# Timestamp always exists for Swarm, but is not present in Aeolus
828+
# Remove datasets of length 0 so that concatenation works
829+
ds_list = [ds for ds in ds_list if ds[self._time_variable].size != 0]
824830
ds = xarray.concat(ds_list, dim=self._time_variable)
825831
else:
826832
# Address complex concatenation case for VirES for Aeolus

0 commit comments

Comments
 (0)