Repository: pandas-dev/pandas

Issue:
Write partitioned Parquet file using to_parquet
Hi, 

I'm trying to write a partitioned Parquet file using the `to_parquet` function:

```python
df.to_parquet('table_name', engine='pyarrow', partition_cols = ['partone', 'parttwo'])
TypeError: __cinit__() got an unexpected keyword argument 'partition_cols'
```
#### Problem description
It was my understanding that the `to_parquet` method pass the kwargs to Pyarrow and save a partitioned table. 

#### Expected Output
Partitioned Parquet file saved.
#### Output of ``pd.show_versions()``

<details>

INSTALLED VERSIONS
------------------
commit: None
python: 3.5.3.final.0
python-bits: 64
OS: Linux
OS-release: 4.9.0-5-amd64
machine: x86_64
processor: 
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
LOCALE: en_US.UTF-8

pandas: 0.23.4
pytest: None
pip: 18.0
setuptools: 32.3.1
Cython: None
numpy: 1.15.2
scipy: 1.1.0
pyarrow: 0.11.0
xarray: None
IPython: 7.0.1
sphinx: None
patsy: None
dateutil: 2.7.3
pytz: 2018.5
blosc: None
bottleneck: None
tables: None
numexpr: None
feather: None
matplotlib: 3.0.0
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: None
lxml: None
bs4: None
html5lib: 1.0.1
sqlalchemy: None
pymysql: None
psycopg2: None
jinja2: 2.10
s3fs: None
fastparquet: None
pandas_gbq: None
pandas_datareader: None

</details>

Thanks!
Converting series of dates to Periods 
#### Code Sample, a copy-pastable example if possible

```python
import pandas as pd

dates = pd.Series(pd.date_range('2014-01-01', '2017-01-01', freq='MS'))

# This fails...
pd.PeriodIndex(dates, freq='M')
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-3-687a0b3d3b9a> in <module>
----> 1 pd.PeriodIndex(dates, freq='M')

~/git/pandas/pandas/core/indexes/period.py in __new__(cls, data, ordinal, freq, start, end, periods, tz, dtype, copy, name, **fields)
    221             else:
    222                 # don't pass copy here, since we copy later.
--> 223                 data = period_array(data=data, freq=freq)
    224 
    225         if copy:

~/git/pandas/pandas/core/arrays/period.py in period_array(data, freq, copy)
    920     """
    921     if is_datetime64_dtype(data):
--> 922         return PeriodArray._from_datetime64(data, freq)
    923     if isinstance(data, (ABCPeriodIndex, ABCSeries, PeriodArray)):
    924         return PeriodArray(data, freq)

~/git/pandas/pandas/core/arrays/period.py in _from_datetime64(cls, data, freq, tz)
    234         PeriodArray[freq]
    235         """
--> 236         data, freq = dt64arr_to_periodarr(data, freq, tz)
    237         return cls(data, freq=freq)
    238 

~/git/pandas/pandas/core/arrays/period.py in dt64arr_to_periodarr(data, freq, tz)
    983         elif freq != data.dt.freq:
    984             msg = DIFFERENT_FREQ_INDEX.format(freq.freqstr,
--> 985                                               data.dt.freq.freqstr)
    986             raise IncompatibleFrequency(msg)
    987         data = data._values

AttributeError: 'str' object has no attribute 'freqstr'

# As does this
dates.to_period('M')

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-5-944b687ce2da> in <module>
----> 1 dates.to_period('M')

~/git/pandas/pandas/core/series.py in to_period(self, freq, copy)
   4108             new_values = new_values.copy()
   4109 
-> 4110         new_index = self.index.to_period(freq=freq)
   4111         return self._constructor(new_values,
   4112                                  index=new_index).__finalize__(self)

AttributeError: 'RangeIndex' object has no attribute 'to_period'

```
#### Problem description

A pandas series of datetimes can't be easily converted to PeriodIndexes anymore. These work under older versions of pandas, but fail now on GitHub's master.

#### Expected Output

Just don't fail...

#### Output of ``pd.show_versions()``

<details>

INSTALLED VERSIONS
------------------
commit: None
python: 3.6.6.final.0
python-bits: 64
OS: Darwin
OS-release: 18.0.0
machine: x86_64
processor: i386
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
LOCALE: en_US.UTF-8

pandas: 0.24.0.dev0+850.g62a15fa40
pytest: 3.9.3
pip: 18.1
setuptools: 40.5.0
Cython: 3.0a0
numpy: 1.16.0.dev0+45718fd
scipy: 1.2.0.dev0+016a6ef
pyarrow: None
xarray: None
IPython: 7.1.1
sphinx: None
patsy: 0.5.1
dateutil: 2.7.5
pytz: 2018.6
blosc: None
bottleneck: None
tables: None
numexpr: None
feather: None
matplotlib: None
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: None
lxml: None
bs4: None
html5lib: None
sqlalchemy: None
pymysql: None
psycopg2: None
jinja2: 2.10
s3fs: None
fastparquet: None
pandas_gbq: None
pandas_datareader: None
gcsfs: None

</details>



Discussion:

Resolving patch:
diff --git a/pandas/io/formats/format.py b/pandas/io/formats/format.py
--- a/pandas/io/formats/format.py
+++ b/pandas/io/formats/format.py
@@ -608,11 +608,6 @@ def to_string(self):
             else:  # max_cols == 0. Try to fit frame to terminal
                 text = self.adj.adjoin(1, *strcols).split('\n')
                 max_len = Series(text).str.len().max()
-                headers = [ele[0] for ele in strcols]
-                # Size of last col determines dot col size. See
-                # `self._to_str_columns
-                size_tr_col = len(headers[self.tr_size_col])
-                max_len += size_tr_col  # Need to make space for largest row
                 # plus truncate dot col
                 dif = max_len - self.w
                 # '+ 1' to avoid too wide repr (GH PR #17023)


Test patch:
diff --git a/pandas/tests/io/formats/test_format.py b/pandas/tests/io/formats/test_format.py
--- a/pandas/tests/io/formats/test_format.py
+++ b/pandas/tests/io/formats/test_format.py
@@ -305,14 +305,10 @@ def test_repr_non_interactive(self):
             assert not has_truncated_repr(df)
             assert not has_expanded_repr(df)
 
-    def test_repr_truncates_terminal_size(self):
+    def test_repr_truncates_terminal_size(self, mock):
         # https://github.com/pandas-dev/pandas/issues/21180
         # TODO: use mock fixutre.
         # This is being backported, so doing it directly here.
-        try:
-            from unittest import mock
-        except ImportError:
-            mock = pytest.importorskip("mock")
 
         terminal_size = (118, 96)
         p1 = mock.patch('pandas.io.formats.console.get_terminal_size',
@@ -343,6 +339,17 @@ def test_repr_truncates_terminal_size(self):
 
         assert df2.columns[0] in result.split('\n')[0]
 
+    def test_repr_truncates_terminal_size_full(self, mock):
+        # GH 22984 ensure entire window is filled
+        terminal_size = (80, 24)
+        df = pd.DataFrame(np.random.rand(1, 7))
+        p1 = mock.patch('pandas.io.formats.console.get_terminal_size',
+                        return_value=terminal_size)
+        p2 = mock.patch('pandas.io.formats.format.get_terminal_size',
+                        return_value=terminal_size)
+        with p1, p2:
+            assert "..." not in str(df)
+
     def test_repr_max_columns_max_rows(self):
         term_width, term_height = get_terminal_size()
         if term_width < 10 or term_height < 10: