Repository: pydata/xarray

Issue:
Remove the `Dataset.T` property?
The fact that `ds.T` transposes a dataset rather than returning `ds['T']` is a repeated point of confusion:
http://stackoverflow.com/questions/41879269/xarray-dataarray-opens-as-a-dataset/41885639#41885639
http://stackoverflow.com/questions/40270929/how-to-read-a-variable-called-t-with-xarray

Discussion:
rabernat: This is great. I hit this annoyance all the time with any dataset from the IRI data library:
http://iridl.ldeo.columbia.edu/

The time dimension is always called `T`.

Patch:
diff --git a/doc/api.rst b/doc/api.rst
index 47cc71b1..17deb56a 100644
--- a/doc/api.rst
+++ b/doc/api.rst
@@ -158,7 +158,6 @@ Computation
 :py:attr:`~Dataset.imag`
 :py:attr:`~Dataset.round`
 :py:attr:`~Dataset.real`
-:py:attr:`~Dataset.T`
 :py:attr:`~Dataset.cumsum`
 :py:attr:`~Dataset.cumprod`
 
diff --git a/doc/whats-new.rst b/doc/whats-new.rst
index a3d78f73..e3d63e7f 100644
--- a/doc/whats-new.rst
+++ b/doc/whats-new.rst
@@ -78,6 +78,9 @@ Breaking changes
   disk when calling ``repr`` (:issue:`1522`).
   By `Guido Imperiale <https://github.com/crusaderky>`_.
 
+- ``Dataset.T`` has been deprecated an alias for ``Dataset.transpose()``
+  (:issue:`1232`).
+
 
 Backward Incompatible Changes
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
diff --git a/xarray/core/dataset.py b/xarray/core/dataset.py
index 8691e7e8..92b29236 100644
--- a/xarray/core/dataset.py
+++ b/xarray/core/dataset.py
@@ -2189,6 +2189,10 @@ class Dataset(Mapping, ImplementsDatasetReduce, BaseDataObject,
 
     @property
     def T(self):
+        warnings.warn('xarray.Dataset.T has been deprecated as an alias for '
+                      '`.transpose()`. It will be removed in a future version '
+                      'of xarray.',
+                      FutureWarning, stacklevel=2)
         return self.transpose()
 
     def dropna(self, dim, how='any', thresh=None, subset=None):


Test patch:
diff --git a/xarray/tests/test_dataset.py b/xarray/tests/test_dataset.py
index c7ea80d5..31678036 100644
--- a/xarray/tests/test_dataset.py
+++ b/xarray/tests/test_dataset.py
@@ -3576,7 +3576,8 @@ class TestDataset(TestCase):
         expected = ds.apply(lambda x: x.transpose())
         self.assertDatasetIdentical(expected, actual)
 
-        actual = ds.T
+        with pytest.warns(FutureWarning):
+            actual = ds.T
         self.assertDatasetIdentical(expected, actual)
 
         actual = ds.transpose('x', 'y')