Repository: bokeh/bokeh

Issue:
Pandas sort deprecated in new charts, use sort_values instead
Getting this deprecation warning when using the new charts.

```
/anaconda/envs/training/lib/python3.4/site-packages/bokeh/charts/_attributes.py:78: FutureWarning: sort(columns=....) is deprecated, use sort_values(by=.....)
  df = df.sort(columns=columns)
```

Switch to using sort_values instead.

cc: @fpliger 



Discussion:
Just had the same waning. See below :

```
d:\dev\python34\lib\site-packages\bokeh\charts\_attributes.py:78: FutureWarning: sort(columns=....) is deprecated, use sort_values(by=.....)
  df = df.sort(columns=columns)
```

There's not much we can do about this now, Pandas changed upstream, which is out of our control. If we move to `sort_values` then still-very-recent versions of Pandas will no longer work, which seems more undesirable than the warning. 

wait... this should be fixed! I made a change to use `sort_values` and use `sort` in case of the exception for older versions of pandas...

(didn't do this for examples though)

Maybe something slipped though? If there is a "compat" layer (I do seem to recall that now) then it would be great to use it on these cases. 

@bryevdv here's part of the fixes that I'm referring to: https://github.com/bokeh/bokeh/blob/master/bokeh/charts/attributes.py#L149-L152

I'm confused... the PR that is referring to this issue ( #3637 ) has nothing to do with with it. It's instead mostly docs and flakes fixes... Maybe it's because of a PR title (and intent) change?

#3637 originally update to `sort_values` directly but that change was reverted.

Edit: it originally had this commit: https://github.com/bokeh/bokeh/commit/42c95052bc4ce8b014e8f0da616d83a608f7e35c But was reverted for the reason I gave (would break with older versions pandas) so now that PR has nothing to do with this issue anymore. It's not really relevant to fixing this issue, which should now happen separately, if at all. 

The examples, I think we have to leave as-is but `builder.py` and `donut_builder.py` could be fixed in the way you show above. 

Aaaah, now I see.. Yeap, this slipped. We can create a `compat` at bokeh level and put it there.. Otherwise, as it's a `charts` only thing we can just use `charts.utils`.


Resolving patch:
diff --git a/bokeh/charts/builder.py b/bokeh/charts/builder.py
--- a/bokeh/charts/builder.py
+++ b/bokeh/charts/builder.py
@@ -564,7 +564,6 @@ class XYBuilder(Builder):
     def set_ranges(self):
         """Calculate and set the x and y ranges."""
         # ToDo: handle when only single dimension is provided
-
         extents = self.get_dim_extents()
 
         endx = extents['x_max']
@@ -623,7 +622,14 @@ def _get_range(self, dim, start, end):
         if dtype == 'object':
             factors = values.drop_duplicates()
             if sort:
-                factors.sort(inplace=True)
+                # TODO (fpliger):   this handles pandas API change so users do not experience
+                #                   the related annoying deprecation warning. This is probably worth
+                #                   removing when pandas deprecated version (0.16) is "old" enough
+                try:
+                    factors.sort_values(inplace=True)
+                except AttributeError:
+                    factors.sort(inplace=True)
+
             setattr(self, dim + 'scale', 'categorical')
             return FactorRange(factors=factors.tolist())
         elif 'datetime' in dtype:
diff --git a/bokeh/charts/builders/donut_builder.py b/bokeh/charts/builders/donut_builder.py
--- a/bokeh/charts/builders/donut_builder.py
+++ b/bokeh/charts/builders/donut_builder.py
@@ -85,7 +85,7 @@ def Donut(data, label='index', values=None,  color=None, agg=None,
 
         # filter by countries with at least one medal and sort by total medals
         df = df[df['total'] > 8]
-        df = df.sort("total", ascending=False)
+        df = df.sort_values(by="total", ascending=False)
         df = pd.melt(df, id_vars=['abbr'],
                      value_vars=['bronze', 'silver', 'gold'],
                      value_name='medal_count', var_name='medal')


Test patch: