Skip to content

Commit 1c49caf

Browse files
DOC: fix code-block ipython highlighting
I noticed some warnings in the travis doc build log in the sense of "WARNING: Could not parse literal_block as "python". highlighting skipped." This was because some of the `.. code-block:: python` directives contained code that could not be interpreted as python. And, additionally, these code blocks were also not highlighted correctly (the `In [1]` prompt were not recognized by the default python highlighter). Therefore, I changed those `.. code-block:: python` directives containing IPython prompt to `.. code-block:: ipython` Author: Joris Van den Bossche <[email protected]> Closes #12853 from jorisvandenbossche/fix-ipython-highlighting and squashes the following commits: 1e104cc [Joris Van den Bossche] DOC: fix code-block ipython highlighting
1 parent b8ae20e commit 1c49caf

24 files changed

+112
-112
lines changed

doc/source/advanced.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -790,7 +790,7 @@ In float indexes, slicing using floats is allowed
790790
791791
In non-float indexes, slicing using floats will raise a ``TypeError``
792792
793-
.. code-block:: python
793+
.. code-block:: ipython
794794
795795
In [1]: pd.Series(range(5))[3.5]
796796
TypeError: the label [3.5] is not a proper indexer for this index type (Int64Index)
@@ -802,7 +802,7 @@ In non-float indexes, slicing using floats will raise a ``TypeError``
802802
803803
Using a scalar float indexer for ``.iloc`` has been removed in 0.18.0, so the following will raise a ``TypeError``
804804
805-
.. code-block:: python
805+
.. code-block:: ipython
806806
807807
In [3]: pd.Series(range(5)).iloc[3.0]
808808
TypeError: cannot do positional indexing on <class 'pandas.indexes.range.RangeIndex'> with these indexers [3.0] of <type 'float'>

doc/source/basics.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ To evaluate single-element pandas objects in a boolean context, use the method
272272

273273
.. code-block:: python
274274
275-
>>>if df:
275+
>>> if df:
276276
...
277277
278278
Or
@@ -352,7 +352,7 @@ objects of the same length:
352352
Trying to compare ``Index`` or ``Series`` objects of different lengths will
353353
raise a ValueError:
354354

355-
.. code-block:: python
355+
.. code-block:: ipython
356356
357357
In [55]: pd.Series(['foo', 'bar', 'baz']) == pd.Series(['foo', 'bar'])
358358
ValueError: Series lengths must match to compare

doc/source/computation.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ These are created from methods on ``Series`` and ``DataFrame``.
236236
237237
These object provide tab-completion of the avaible methods and properties.
238238

239-
.. code-block:: python
239+
.. code-block:: ipython
240240
241241
In [14]: r.
242242
r.agg r.apply r.count r.exclusions r.max r.median r.name r.skew r.sum

doc/source/enhancingperf.rst

+6-6
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ Here's the function in pure python:
6868
6969
We achieve our result by using ``apply`` (row-wise):
7070

71-
.. code-block:: python
71+
.. code-block:: ipython
7272
7373
In [7]: %timeit df.apply(lambda x: integrate_f(x['a'], x['b'], x['N']), axis=1)
7474
10 loops, best of 3: 174 ms per loop
@@ -125,7 +125,7 @@ is here to distinguish between function versions):
125125
to be using bleeding edge ipython for paste to play well with cell magics.
126126

127127

128-
.. code-block:: python
128+
.. code-block:: ipython
129129
130130
In [4]: %timeit df.apply(lambda x: integrate_f_plain(x['a'], x['b'], x['N']), axis=1)
131131
10 loops, best of 3: 85.5 ms per loop
@@ -154,7 +154,7 @@ We get another huge improvement simply by providing type information:
154154
...: return s * dx
155155
...:
156156

157-
.. code-block:: python
157+
.. code-block:: ipython
158158
159159
In [4]: %timeit df.apply(lambda x: integrate_f_typed(x['a'], x['b'], x['N']), axis=1)
160160
10 loops, best of 3: 20.3 ms per loop
@@ -234,7 +234,7 @@ the rows, applying our ``integrate_f_typed``, and putting this in the zeros arra
234234
Loops like this would be *extremely* slow in python, but in Cython looping
235235
over numpy arrays is *fast*.
236236

237-
.. code-block:: python
237+
.. code-block:: ipython
238238
239239
In [4]: %timeit apply_integrate_f(df['a'].values, df['b'].values, df['N'].values)
240240
1000 loops, best of 3: 1.25 ms per loop
@@ -284,7 +284,7 @@ advanced cython techniques:
284284
...: return res
285285
...:
286286

287-
.. code-block:: python
287+
.. code-block:: ipython
288288
289289
In [4]: %timeit apply_integrate_f_wrap(df['a'].values, df['b'].values, df['N'].values)
290290
1000 loops, best of 3: 987 us per loop
@@ -348,7 +348,7 @@ Using ``numba`` to just-in-time compile your code. We simply take the plain pyth
348348
349349
Note that we directly pass ``numpy`` arrays to the numba function. ``compute_numba`` is just a wrapper that provides a nicer interface by passing/returning pandas objects.
350350

351-
.. code-block:: python
351+
.. code-block:: ipython
352352
353353
In [4]: %timeit compute_numba(df)
354354
1000 loops, best of 3: 798 us per loop

doc/source/indexing.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ Selection By Label
297297
dfl = pd.DataFrame(np.random.randn(5,4), columns=list('ABCD'), index=pd.date_range('20130101',periods=5))
298298
dfl
299299
300-
.. code-block:: python
300+
.. code-block:: ipython
301301
302302
In [4]: dfl.loc[2:3]
303303
TypeError: cannot do slice indexing on <class 'pandas.tseries.index.DatetimeIndex'> with these indexers [2] of <type 'int'>

doc/source/io.rst

+5-5
Original file line numberDiff line numberDiff line change
@@ -4375,7 +4375,7 @@ Creating BigQuery Tables
43754375
As of 0.15.2, the gbq module has a function :func:`~pandas.io.gbq.generate_bq_schema` which will
43764376
produce the dictionary representation schema of the specified pandas DataFrame.
43774377

4378-
.. code-block:: python
4378+
.. code-block:: ipython
43794379
43804380
In [10]: gbq.generate_bq_schema(df, default_type='STRING')
43814381
@@ -4633,7 +4633,7 @@ Performance Considerations
46334633

46344634
This is an informal comparison of various IO methods, using pandas 0.13.1.
46354635

4636-
.. code-block:: python
4636+
.. code-block:: ipython
46374637
46384638
In [1]: df = DataFrame(randn(1000000,2),columns=list('AB'))
46394639
@@ -4648,7 +4648,7 @@ This is an informal comparison of various IO methods, using pandas 0.13.1.
46484648
46494649
Writing
46504650

4651-
.. code-block:: python
4651+
.. code-block:: ipython
46524652
46534653
In [14]: %timeit test_sql_write(df)
46544654
1 loops, best of 3: 6.24 s per loop
@@ -4670,7 +4670,7 @@ Writing
46704670
46714671
Reading
46724672

4673-
.. code-block:: python
4673+
.. code-block:: ipython
46744674
46754675
In [18]: %timeit test_sql_read()
46764676
1 loops, best of 3: 766 ms per loop
@@ -4692,7 +4692,7 @@ Reading
46924692
46934693
Space on disk (in bytes)
46944694

4695-
.. code-block:: python
4695+
.. code-block::
46964696
46974697
25843712 Apr 8 14:11 test.sql
46984698
24007368 Apr 8 14:11 test_fixed.hdf

doc/source/options.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ Setting Startup Options in python/ipython Environment
130130

131131
Using startup scripts for the python/ipython environment to import pandas and set options makes working with pandas more efficient. To do this, create a .py or .ipy script in the startup directory of the desired profile. An example where the startup folder is in a default ipython profile can be found at:
132132

133-
.. code-block:: python
133+
.. code-block:: none
134134
135135
$IPYTHONDIR/profile_default/startup
136136

doc/source/release.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -1521,7 +1521,7 @@ API Changes
15211521
of the future import. You can use ``//`` and ``floordiv`` to do integer
15221522
division.
15231523

1524-
.. code-block:: python
1524+
.. code-block:: ipython
15251525
15261526
In [3]: arr = np.array([1, 2, 3, 4])
15271527

doc/source/remote_data.rst

+6-6
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ every world bank indicator is accessible.
192192
For example, if you wanted to compare the Gross Domestic Products per capita in
193193
constant dollars in North America, you would use the ``search`` function:
194194

195-
.. code-block:: python
195+
.. code-block:: ipython
196196
197197
In [1]: from pandas.io import wb
198198
@@ -207,7 +207,7 @@ constant dollars in North America, you would use the ``search`` function:
207207
Then you would use the ``download`` function to acquire the data from the World
208208
Bank's servers:
209209

210-
.. code-block:: python
210+
.. code-block:: ipython
211211
212212
In [3]: dat = wb.download(indicator='NY.GDP.PCAP.KD', country=['US', 'CA', 'MX'], start=2005, end=2008)
213213
@@ -230,7 +230,7 @@ Bank's servers:
230230
The resulting dataset is a properly formatted ``DataFrame`` with a hierarchical
231231
index, so it is easy to apply ``.groupby`` transformations to it:
232232

233-
.. code-block:: python
233+
.. code-block:: ipython
234234
235235
In [6]: dat['NY.GDP.PCAP.KD'].groupby(level=0).mean()
236236
Out[6]:
@@ -243,7 +243,7 @@ index, so it is easy to apply ``.groupby`` transformations to it:
243243
Now imagine you want to compare GDP to the share of people with cellphone
244244
contracts around the world.
245245

246-
.. code-block:: python
246+
.. code-block:: ipython
247247
248248
In [7]: wb.search('cell.*%').iloc[:,:2]
249249
Out[7]:
@@ -255,7 +255,7 @@ contracts around the world.
255255
Notice that this second search was much faster than the first one because
256256
``pandas`` now has a cached list of available data series.
257257

258-
.. code-block:: python
258+
.. code-block:: ipython
259259
260260
In [13]: ind = ['NY.GDP.PCAP.KD', 'IT.MOB.COV.ZS']
261261
In [14]: dat = wb.download(indicator=ind, country='all', start=2011, end=2011).dropna()
@@ -273,7 +273,7 @@ Finally, we use the ``statsmodels`` package to assess the relationship between
273273
our two variables using ordinary least squares regression. Unsurprisingly,
274274
populations in rich countries tend to use cellphones at a higher rate:
275275

276-
.. code-block:: python
276+
.. code-block:: ipython
277277
278278
In [17]: import numpy as np
279279
In [18]: import statsmodels.formula.api as smf

doc/source/timeseries.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -1522,7 +1522,7 @@ If ``Period`` freq is daily or higher (``D``, ``H``, ``T``, ``S``, ``L``, ``U``,
15221522
p + timedelta(minutes=120)
15231523
p + np.timedelta64(7200, 's')
15241524
1525-
.. code-block:: python
1525+
.. code-block:: ipython
15261526
15271527
In [1]: p + Minute(5)
15281528
Traceback
@@ -1536,7 +1536,7 @@ If ``Period`` has other freqs, only the same ``offsets`` can be added. Otherwise
15361536
p = Period('2014-07', freq='M')
15371537
p + MonthEnd(3)
15381538
1539-
.. code-block:: python
1539+
.. code-block:: ipython
15401540
15411541
In [1]: p + MonthBegin(3)
15421542
Traceback

doc/source/whatsnew/v0.10.0.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ nfrequencies are unaffected. The prior defaults were causing a great deal of
7070
confusion for users, especially resampling data to daily frequency (which
7171
labeled the aggregated group with the end of the interval: the next day).
7272

73-
.. code-block:: python
73+
.. code-block:: ipython
7474

7575
In [1]: dates = pd.date_range('1/1/2000', '1/5/2000', freq='4h')
7676

doc/source/whatsnew/v0.12.0.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ I/O Enhancements
252252
- Iterator support via ``read_hdf`` that automatically opens and closes the
253253
store when iteration is finished. This is only for *tables*
254254

255-
.. code-block:: python
255+
.. code-block:: ipython
256256

257257
In [25]: path = 'store_iterator.h5'
258258

doc/source/whatsnew/v0.13.0.txt

+4-4
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ API changes
8080

8181
Integer division
8282

83-
.. code-block:: python
83+
.. code-block:: ipython
8484

8585
In [3]: arr = np.array([1, 2, 3, 4])
8686

@@ -99,7 +99,7 @@ API changes
9999

100100
True Division
101101

102-
.. code-block:: python
102+
.. code-block:: ipython
103103

104104
In [7]: pd.Series(arr) / pd.Series(arr2) # no future import required
105105
Out[7]:
@@ -304,7 +304,7 @@ Float64Index API Change
304304
- Indexing on other index types are preserved (and positional fallback for ``[],ix``), with the exception, that floating point slicing
305305
on indexes on non ``Float64Index`` will now raise a ``TypeError``.
306306

307-
.. code-block:: python
307+
.. code-block:: ipython
308308

309309
In [1]: Series(range(5))[3.5]
310310
TypeError: the label [3.5] is not a proper indexer for this index type (Int64Index)
@@ -314,7 +314,7 @@ Float64Index API Change
314314

315315
Using a scalar float indexer will be deprecated in a future version, but is allowed for now.
316316

317-
.. code-block:: python
317+
.. code-block:: ipython
318318

319319
In [3]: Series(range(5))[3.0]
320320
Out[3]: 3

doc/source/whatsnew/v0.14.0.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ API changes
170170
:ref:`Computing rolling pairwise covariances and correlations
171171
<stats.moments.corr_pairwise>` in the docs.
172172

173-
.. code-block:: python
173+
.. code-block:: ipython
174174

175175
In [1]: df = DataFrame(np.random.randn(10,4),columns=list('ABCD'))
176176

@@ -661,7 +661,7 @@ Deprecations
661661
- Indexers will warn ``FutureWarning`` when used with a scalar indexer and
662662
a non-floating point Index (:issue:`4892`, :issue:`6960`)
663663

664-
.. code-block:: python
664+
.. code-block:: ipython
665665

666666
# non-floating point indexes can only be indexed by integers / labels
667667
In [1]: Series(1,np.arange(5))[3.0]

doc/source/whatsnew/v0.14.1.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ API changes
4848
offsets (BusinessMonthBegin, MonthEnd, BusinessMonthEnd, CustomBusinessMonthEnd,
4949
BusinessYearBegin, LastWeekOfMonth, FY5253Quarter, LastWeekOfMonth, Easter):
5050

51-
.. code-block:: python
51+
.. code-block:: ipython
5252

5353
In [6]: from pandas.tseries import offsets
5454

0 commit comments

Comments
 (0)