Repository: pandas-dev/pandas

Issue:
header='infer' is not working when there is no header
#### Code Sample

```python
import tempfile
import pandas as pd

df = pd.DataFrame({'AAA' : [4,5,6,7], 'BBB' : [10,20,30,40],'CCC' : [100,50,-30,-50]})
tmp = tempfile.mkstemp()[1]
df.to_csv(tmp, header=False)
df = pd.read_csv(tmp, header='infer')
print(df)
```

#### Output

```
0 | 4 | 10 | 100
--| --| -- | --
1 | 5 | 20 | 50
2 | 6 | 30 | -30
3 | 7 | 40 | -50


```

Pandas cannot infer that there is no header in csv files even though I use `header='infer'` argument in `read_csv`.

#### Expected Output

```

0 | 1 | 2  | 3
--| --| -- | --
0 | 4 | 10 | 100
1 | 5 | 20 | 50
2 | 6 | 30 | -30
3 | 7 | 40 | -50

```

I expect header inference to work properly and return a dataframe with 4 rows here. See `data.table` R package for a working header inference implementation[[1](https://github.com/Rdatatable/data.table/blob/master/src/fread.c#L638)].

#### Output of ``pd.show_versions()``

<details>

INSTALLED VERSIONS
------------------
commit: None
python: 3.6.2.final.0
python-bits: 64
OS: Darwin
OS-release: 16.7.0
machine: x86_64
processor: i386
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
LOCALE: en_US.UTF-8

pandas: 0.20.3
pytest: 3.2.1
pip: 9.0.1
setuptools: 27.2.0
Cython: 0.26
numpy: 1.13.1
scipy: 0.19.1
xarray: None
IPython: 6.1.0
sphinx: None
patsy: 0.4.1
dateutil: 2.6.1
pytz: 2017.2
blosc: None
bottleneck: None
tables: None
numexpr: None
feather: None
matplotlib: 2.0.2
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: None
lxml: None
bs4: None
html5lib: 0.9999999
sqlalchemy: None
pymysql: None
psycopg2: None
jinja2: 2.9.6
s3fs: None
pandas_gbq: None
pandas_datareader: None

</details>



Discussion:
@gokceneraslan : Thanks for this report!  This is a documentation issue.  When you pass in `infer`, that is interpreted as there being a header available.  For round-trip, you should pass in `header=None`.

Nevertheless, the documentation for the `header` parameter could be improved to make these behaviors clearer to the user.  PR is welcome!

Resolving patch:
diff --git a/pandas/io/parsers.py b/pandas/io/parsers.py
--- a/pandas/io/parsers.py
+++ b/pandas/io/parsers.py
@@ -74,15 +74,19 @@
     .. versionadded:: 0.18.1 support for the Python parser.
 
 header : int or list of ints, default 'infer'
-    Row number(s) to use as the column names, and the start of the data.
-    Default behavior is as if set to 0 if no ``names`` passed, otherwise
-    ``None``. Explicitly pass ``header=0`` to be able to replace existing
-    names. The header can be a list of integers that specify row locations for
-    a multi-index on the columns e.g. [0,1,3]. Intervening rows that are not
-    specified will be skipped (e.g. 2 in this example is skipped). Note that
-    this parameter ignores commented lines and empty lines if
-    ``skip_blank_lines=True``, so header=0 denotes the first line of data
-    rather than the first line of the file.
+    Row number(s) to use as the column names, and the start of the
+    data.  Default behavior is to infer the column names: if no names
+    are passed the behavior is identical to ``header=0`` and column
+    names are inferred from the first line of the file, if column
+    names are passed explicitly then the behavior is identical to
+    ``header=None``. Explicitly pass ``header=0`` to be able to
+    replace existing names. The header can be a list of integers that
+    specify row locations for a multi-index on the columns
+    e.g. [0,1,3]. Intervening rows that are not specified will be
+    skipped (e.g. 2 in this example is skipped). Note that this
+    parameter ignores commented lines and empty lines if
+    ``skip_blank_lines=True``, so header=0 denotes the first line of
+    data rather than the first line of the file.
 names : array-like, default None
     List of column names to use. If file contains no header row, then you
     should explicitly pass header=None. Duplicates in this list will cause


Test patch: