Skip to content

Commit

Permalink
minor code clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
jmunroe committed Jul 27, 2017
1 parent 104ab49 commit 63d7fd3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
5 changes: 1 addition & 4 deletions xarray/core/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -2327,11 +2327,9 @@ def to_array(self, dim='variable', name=None):

def _to_dataframe(self, ordered_dims):
columns = [k for k in self if k not in self.dims]

index = self.coords.to_index(ordered_dims)

data = [self._variables[k].set_dims(ordered_dims).values.reshape(-1)
for k in columns]
index = self.coords.to_index(ordered_dims)
return pd.DataFrame(OrderedDict(zip(columns, data)), index=index)

def to_dataframe(self):
Expand Down Expand Up @@ -2414,7 +2412,6 @@ def to_dask_dataframe(self, set_index=True):

return df


def to_dict(self):
"""
Convert this dataset to a dictionary following xarray naming
Expand Down
6 changes: 3 additions & 3 deletions xarray/tests/test_dask.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
with suppress(ImportError):
import dask
import dask.array as da
import dask.dataframe
import dask.dataframe as dd


class DaskTestCase(TestCase):
Expand Down Expand Up @@ -407,12 +407,12 @@ def test_to_dask_dataframe(self):
expected_pd = pd.DataFrame(np.array([x, y]).T,
columns=['a', 'b'],
index=pd.Index(t, name='t'))
expected = dask.dataframe.from_pandas(expected_pd, chunksize=4)
expected = dd.from_pandas(expected_pd, chunksize=4)

actual = ds.to_dask_dataframe()

# test if we have dask dataframes
self.assertIsInstance(actual, dask.dataframe.DataFrame)
self.assertIsInstance(actual, dd.DataFrame)

# use the .equals from pandas to check dataframes are equivalent
assert expected.compute().equals(actual.compute()), (expected, actual)
Expand Down

0 comments on commit 63d7fd3

Please sign in to comment.