ENH: Add support for writing variable labels to Stata files
State: closed

- [x] closes #13536
- [x] closes #13535
- [x] tests added / passed
- [x] passes `git diff upstream/master | flake8 --diff`
- [x] whatsnew entry

Add support for writing variable labels
Fix documentation for to_stata
Clean up function name to improve readability

closes #13536
closes #13535


Labels:
name: Enhancement
name: IO Stata
description: read_stata, to_stata

Comments:
Just the one minor note, plus a whatsnew entry (this can go in 0.19). Other than that this looks great assuming Travis passes.

It will fail on Python 2.7 I can see now.  But should be easy enough to fix.

## [Current coverage](https://codecov.io/gh/pydata/pandas/pull/13631?src=pr) is **84.38%**

> Merging [#13631](https://codecov.io/gh/pydata/pandas/pull/13631?src=pr) into [master](https://codecov.io/gh/pydata/pandas/branch/master?src=pr) will increase coverage by **<.01%**

``` diff
@@             master     #13631   diff @@
==========================================
  Files           142        142          
  Lines         51223      51235    +12   
  Methods           0          0          
  Messages          0          0          
  Branches          0          0          
==========================================
+ Hits          43223      43235    +12   
  Misses         8000       8000          
  Partials          0          0          
```

> Powered by [Codecov](https://codecov.io?src=pr). Last updated by [d7c028d...1e1e1bf](https://codecov.io/gh/pydata/pandas/compare/d7c028d4965932160fa3b69f56c716b1454c42a5...1e1e1bf6473ccedbf0e04ff5cdd92def1ec4abf3?src=pr)

is this forward compat? IOW, righting the labels should then be readable by older versions of pandas? 

> is this forward compat? IOW, righting the labels should then be readable by older versions of pandas?

Should be -- the reader code always has to read these labels even if it doesn't do anything with them. One can read them using `StataReader` but not sure when the method to read the labels was added.

@TomAugspurger @jreback Sort of unrelated issue, but do have any idea why my Travis fails when running pandas test suite?  My travis always fails even when the pull request into pandas pydata travis works fine.

Most recent example:

https://travis-ci.org/bashtage/pandas/builds/144722347

I see lots of errors like:

```
======================================================================
ERROR: pandas.io.tests.test_pickle.TestPickle.test_pickles('0.18.1',)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/travis/miniconda/envs/pandas/lib/python3.5/site-packages/nose/case.py", line 382, in setUp
    try_run(self.inst, ('setup', 'setUp'))
  File "/home/travis/miniconda/envs/pandas/lib/python3.5/site-packages/nose/util.py", line 471, in try_run
    return func()
  File "/home/travis/build/bashtage/pandas/pandas/io/tests/test_pickle.py", line 38, in setUp
    self.data = create_pickle_data()
  File "/home/travis/build/bashtage/pandas/pandas/io/tests/generate_legacy_storage_files.py", line 168, in create_pickle_data
    if _loose_version < '0.14.1':
  File "/home/travis/miniconda/envs/pandas/lib/python3.5/distutils/version.py", line 52, in __lt__
    c = self._cmp(other)
  File "/home/travis/miniconda/envs/pandas/lib/python3.5/distutils/version.py", line 337, in _cmp
    if self.version < other.version:
TypeError: unorderable types: str() < int()
```

@bashtage you have an older fork; git does not update tags with a fork (not really sure why this doesn't go along with cloning but it doesnt').

so

`git push tags yourbranch master --tags`

will push them up to your fork of master, so future branches should be ok
you can also do this on your current branch.

there is a setup section that shows the gittags (after you update then this will show them)

@jreback All green.

just some formatting changes. can you add a whatsnew entry as well. doc updates if you think are needed as well. ping on green.

@jreback Should be ready

thanks @bashtage