DOC: Fixing more doc warings and wrong .. code-block :: directive (sp… · pandas-dev/pandas@7c842b0 (original) (raw)
`@@ -84,9 +84,9 @@ The new implementation allows for having a single-timezone across all rows, with
`
84
84
``
85
85
`.. ipython:: python
`
86
86
``
87
``
`-
df = DataFrame({'A': date_range('20130101', periods=3),
`
88
``
`-
'B': date_range('20130101', periods=3, tz='US/Eastern'),
`
89
``
`-
'C': date_range('20130101', periods=3, tz='CET')})
`
``
87
`+
df = pd.DataFrame({'A': pd.date_range('20130101', periods=3),
`
``
88
`+
'B': pd.date_range('20130101', periods=3, tz='US/Eastern'),
`
``
89
`+
'C': pd.date_range('20130101', periods=3, tz='CET')})
`
90
90
` df
`
91
91
` df.dtypes
`
92
92
``
`@@ -442,17 +442,18 @@ Other enhancements
`
442
442
``
443
443
``` - Added a DataFrame.round method to round the values to a variable number of decimal places (:issue:10568).
`444`
`444`
``
`445`
``
`-
.. ipython :: python
`
``
`445`
`+
.. ipython:: python
`
`446`
`446`
``
`447`
``
`-
df = pd.DataFrame(np.random.random([3, 3]), columns=['A', 'B', 'C'],
`
`448`
``
`-
index=['first', 'second', 'third'])
`
``
`447`
`+
df = pd.DataFrame(np.random.random([3, 3]),
`
``
`448`
`+
columns=['A', 'B', 'C'],
`
``
`449`
`+
index=['first', 'second', 'third'])
`
`449`
`450`
` df
`
`450`
`451`
` df.round(2)
`
`451`
`452`
` df.round({'A': 0, 'C': 2})
`
`452`
`453`
``
`453`
`454`
``` - ``drop_duplicates`` and ``duplicated`` now accept a ``keep`` keyword to target first, last, and all duplicates. The ``take_last`` keyword is deprecated, see :ref:`here <whatsnew_0170.deprecations>` (:issue:`6511`, :issue:`8505`)
454
455
``
455
``
`-
.. ipython :: python
`
``
456
`+
.. ipython:: python
`
456
457
``
457
458
` s = pd.Series(['A', 'B', 'C', 'A', 'B', 'D'])
`
458
459
` s.drop_duplicates()
`
`@@ -630,13 +631,13 @@ Of course you can coerce this as well.
`
630
631
``
631
632
`.. ipython:: python
`
632
633
``
633
``
`-
to_datetime(['2009-07-31', 'asd'], errors='coerce')
`
``
634
`+
pd.to_datetime(['2009-07-31', 'asd'], errors='coerce')
`
634
635
``
635
636
``` To keep the previous behavior, you can use errors='ignore':
`636`
`637`
``
`637`
`638`
`.. ipython:: python
`
`638`
`639`
``
`639`
``
`-
to_datetime(['2009-07-31', 'asd'], errors='ignore')
`
``
`640`
`+
pd.to_datetime(['2009-07-31', 'asd'], errors='ignore')
`
`640`
`641`
``
`641`
`642`
``` Furthermore, ``pd.to_timedelta`` has gained a similar API, of ``errors='raise'|'ignore'|'coerce'``, and the ``coerce`` keyword
642
643
``` has been deprecated in favor of errors='coerce'.
`@@ -655,13 +656,13 @@ Previous Behavior:
`
`655`
`656`
``
`656`
`657`
`.. code-block:: ipython
`
`657`
`658`
``
`658`
``
`-
In [1]: Timestamp('2012Q2')
`
``
`659`
`+
In [1]: pd.Timestamp('2012Q2')
`
`659`
`660`
` Traceback
`
`660`
`661`
` ...
`
`661`
`662`
` ValueError: Unable to parse 2012Q2
`
`662`
`663`
``
`663`
`664`
` # Results in today's date.
`
`664`
``
`-
In [2]: Timestamp('2014')
`
``
`665`
`+
In [2]: pd.Timestamp('2014')
`
`665`
`666`
` Out [2]: 2014-08-12 00:00:00
`
`666`
`667`
``
`667`
`668`
``` v0.17.0 can parse them as below. It works on ``DatetimeIndex`` also.
`@@ -670,9 +671,9 @@ New Behavior:
`
670
671
``
671
672
`.. ipython:: python
`
672
673
``
673
``
`-
Timestamp('2012Q2')
`
674
``
`-
Timestamp('2014')
`
675
``
`-
DatetimeIndex(['2012Q2', '2014'])
`
``
674
`+
pd.Timestamp('2012Q2')
`
``
675
`+
pd.Timestamp('2014')
`
``
676
`+
pd.DatetimeIndex(['2012Q2', '2014'])
`
676
677
``
677
678
`.. note::
`
678
679
``
`@@ -681,8 +682,8 @@ New Behavior:
`
681
682
` .. ipython:: python
`
682
683
``
683
684
`import pandas.tseries.offsets as offsets
`
684
``
`-
Timestamp.now()
`
685
``
`-
Timestamp.now() + offsets.DateOffset(years=1)
`
``
685
`+
pd.Timestamp.now()
`
``
686
`+
pd.Timestamp.now() + offsets.DateOffset(years=1)
`
686
687
``
687
688
`Changes to Index Comparisons
`
688
689
`^^^^^^^^^^^^^^^^^^^^^^^^^^^^
`
``` @@ -739,7 +740,7 @@ Boolean comparisons of a Series vs None will now be equivalent to compar
`739`
`740`
``
`740`
`741`
`.. ipython:: python
`
`741`
`742`
``
`742`
``
`-
s = Series(range(3))
`
``
`743`
`+
s = pd.Series(range(3))
`
`743`
`744`
` s.iloc[1] = None
`
`744`
`745`
` s
`
`745`
`746`
``
`@@ -807,11 +808,6 @@ Previous Behavior:
`
`807`
`808`
``
`808`
`809`
`New Behavior:
`
`809`
`810`
``
`810`
``
`-
.. ipython:: python
`
`811`
``
`-
:suppress:
`
`812`
``
`-`
`813`
``
`-
import os
`
`814`
``
`-`
`815`
`811`
`.. ipython:: python
`
`816`
`812`
``
`817`
`813`
` df_with_missing.to_hdf('file.h5',
`
`@@ -824,6 +820,7 @@ New Behavior:
`
`824`
`820`
`.. ipython:: python
`
`825`
`821`
` :suppress:
`
`826`
`822`
``
``
`823`
`+
import os
`
`827`
`824`
` os.remove('file.h5')
`
`828`
`825`
``
`829`
`826`
`` See the :ref:`docs <io.hdf5>` for more details.
``
``` @@ -876,7 +873,7 @@ Changes to ``Categorical.unique``
876
873
`- unordered category: values and categories are sorted by appearance order.
`
877
874
`- ordered category: values are sorted by appearance order, categories keep existing order.
`
878
875
``
879
``
`-
.. ipython :: python
`
``
876
`+
.. ipython:: python
`
880
877
``
881
878
` cat = pd.Categorical(['C', 'A', 'B', 'C'],
`
882
879
`categories=['A', 'B', 'C'],
`
``` @@ -899,7 +896,7 @@ an integer, resulting in header=0 for False and header=1 for ``True`
`899`
`896`
``
`900`
`897`
``` A ``bool`` input to ``header`` will now raise a ``TypeError``
901
898
``
902
``
`-
.. code-block :: python
`
``
899
`+
.. code-block:: ipython
`
903
900
``
904
901
` In [29]: df = pd.read_csv('data.csv', header=False)
`
905
902
` TypeError: Passing a bool to header is invalid. Use header=None for no header or
`
`@@ -984,10 +981,12 @@ Removal of prior version deprecations/changes
`
984
981
``` - Removal of colSpace parameter from DataFrame.to_string(), in favor of col_space, circa 0.8.0 version.
`985`
`982`
`` - Removal of automatic time-series broadcasting (:issue:`2304`)
``
`986`
`983`
``
`987`
``
`-
.. ipython :: python
`
``
`984`
`+
.. ipython:: python
`
`988`
`985`
``
`989`
`986`
` np.random.seed(1234)
`
`990`
``
`-
df = DataFrame(np.random.randn(5,2),columns=list('AB'),index=date_range('20130101',periods=5))
`
``
`987`
`+
df = DataFrame(np.random.randn(5, 2),
`
``
`988`
`+
columns=list('AB'),
`
``
`989`
`+
index=date_range('20130101', periods=5))
`
`991`
`990`
` df
`
`992`
`991`
``
`993`
`992`
` Previously
`
`@@ -1008,9 +1007,9 @@ Removal of prior version deprecations/changes
`
`1008`
`1007`
``
`1009`
`1008`
` Current
`
`1010`
`1009`
``
`1011`
``
`-
.. ipython :: python
`
``
`1010`
`+
.. ipython:: python
`
`1012`
`1011`
``
`1013`
``
`-
df.add(df.A,axis='index')
`
``
`1012`
`+
df.add(df.A, axis='index')
`
`1014`
`1013`
``
`1015`
`1014`
``
`1016`
`1015`
``` - Remove ``table`` keyword in ``HDFStore.put/append``, in favor of using ``format=`` (:issue:`4645`)