Skip to content

Commit 151ba51

Browse files
committed
Merge pull request #4972 from alefnula/iss4967
CLN: change print to print() in docs
2 parents b51d54e + 230cbc4 commit 151ba51

13 files changed

+81
-80
lines changed

doc/source/basics.rst

+11-10
Original file line numberDiff line numberDiff line change
@@ -860,7 +860,7 @@ Thus, for example:
860860
.. ipython::
861861

862862
In [0]: for col in df:
863-
...: print col
863+
...: print(col)
864864
...:
865865

866866
iteritems
@@ -878,8 +878,8 @@ For example:
878878
.. ipython::
879879

880880
In [0]: for item, frame in wp.iteritems():
881-
...: print item
882-
...: print frame
881+
...: print(item)
882+
...: print(frame)
883883
...:
884884

885885

@@ -895,19 +895,19 @@ containing the data in each row:
895895
.. ipython::
896896

897897
In [0]: for row_index, row in df2.iterrows():
898-
...: print '%s\n%s' % (row_index, row)
898+
...: print('%s\n%s' % (row_index, row))
899899
...:
900900

901901
For instance, a contrived way to transpose the dataframe would be:
902902

903903
.. ipython:: python
904904
905905
df2 = DataFrame({'x': [1, 2, 3], 'y': [4, 5, 6]})
906-
print df2
907-
print df2.T
906+
print(df2)
907+
print(df2.T)
908908
909909
df2_t = DataFrame(dict((idx,values) for idx, values in df2.iterrows()))
910-
print df2_t
910+
print(df2_t)
911911
912912
.. note::
913913

@@ -918,8 +918,8 @@ For instance, a contrived way to transpose the dataframe would be:
918918
919919
df_iter = DataFrame([[1, 1.0]], columns=['x', 'y'])
920920
row = next(df_iter.iterrows())[1]
921-
print row['x'].dtype
922-
print df_iter['x'].dtype
921+
print(row['x'].dtype)
922+
print(df_iter['x'].dtype)
923923
924924
itertuples
925925
~~~~~~~~~~
@@ -932,7 +932,8 @@ For instance,
932932

933933
.. ipython:: python
934934
935-
for r in df2.itertuples(): print r
935+
for r in df2.itertuples():
936+
print(r)
936937
937938
.. _basics.string_methods:
938939

doc/source/dsintro.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -586,7 +586,7 @@ R package):
586586
.. ipython:: python
587587
588588
baseball = read_csv('data/baseball.csv')
589-
print baseball
589+
print(baseball)
590590
591591
.. ipython:: python
592592
:suppress:
@@ -599,7 +599,7 @@ DataFrame in tabular form, though it won't always fit the console width:
599599

600600
.. ipython:: python
601601
602-
print baseball.iloc[-20:, :12].to_string()
602+
print(baseball.iloc[-20:, :12].to_string())
603603
604604
New since 0.10.0, wide DataFrames will now be printed across multiple rows by
605605
default:

doc/source/gotchas.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ of the new set of columns rather than the original ones:
372372
373373
.. ipython:: python
374374
375-
print open('tmp.csv').read()
375+
print(open('tmp.csv').read())
376376
377377
date_spec = {'nominal': [1, 2], 'actual': [1, 3]}
378378
df = read_csv('tmp.csv', header=None,

doc/source/groupby.rst

+4-4
Original file line numberDiff line numberDiff line change
@@ -282,17 +282,17 @@ natural and functions similarly to ``itertools.groupby``:
282282
In [4]: grouped = df.groupby('A')
283283

284284
In [5]: for name, group in grouped:
285-
...: print name
286-
...: print group
285+
...: print(name)
286+
...: print(group)
287287
...:
288288

289289
In the case of grouping by multiple keys, the group name will be a tuple:
290290

291291
.. ipython::
292292

293293
In [5]: for name, group in df.groupby(['A', 'B']):
294-
...: print name
295-
...: print group
294+
...: print(name)
295+
...: print(group)
296296
...:
297297

298298
It's standard Python-fu but remember you can unpack the tuple in the for loop

doc/source/indexing.rst

+9-9
Original file line numberDiff line numberDiff line change
@@ -1149,7 +1149,7 @@ and stop are **inclusive** in the label-based case:
11491149
.. ipython:: python
11501150
11511151
date1, date2 = dates[[2, 4]]
1152-
print date1, date2
1152+
print(date1, date2)
11531153
df.ix[date1:date2]
11541154
df['A'].ix[date1:date2]
11551155
@@ -1211,10 +1211,10 @@ scalar values, though setting arbitrary vectors is not yet supported:
12111211
12121212
df2 = df[:4]
12131213
df2['foo'] = 'bar'
1214-
print df2
1214+
print(df2)
12151215
df2.ix[2] = np.nan
1216-
print df2
1217-
print df2.dtypes
1216+
print(df2)
1217+
print(df2.dtypes)
12181218
12191219
.. _indexing.view_versus_copy:
12201220

@@ -1639,13 +1639,13 @@ instance:
16391639
midx = MultiIndex(levels=[['zero', 'one'], ['x','y']],
16401640
labels=[[1,1,0,0],[1,0,1,0]])
16411641
df = DataFrame(randn(4,2), index=midx)
1642-
print df
1642+
print(df)
16431643
df2 = df.mean(level=0)
1644-
print df2
1645-
print df2.reindex(df.index, level=0)
1644+
print(df2)
1645+
print(df2.reindex(df.index, level=0))
16461646
df_aligned, df2_aligned = df.align(df2, level=0)
1647-
print df_aligned
1648-
print df2_aligned
1647+
print(df_aligned)
1648+
print(df2_aligned)
16491649
16501650
16511651
The need for sortedness with :class:`~pandas.MultiIndex`

0 commit comments

Comments
 (0)