Skip to content

Commit 4725adb

Browse files
charlesdong1991Pingviinituutti
authored andcommitted
DOC: update usage of randn in io.rst (pandas-dev#24154)
1 parent e3fe170 commit 4725adb

File tree

1 file changed

+20
-20
lines changed

1 file changed

+20
-20
lines changed

doc/source/io.rst

+20-20
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
from pandas.compat import StringIO, BytesIO
1515
1616
17-
randn = np.random.randn
1817
np.set_printoptions(precision=4, suppress=True)
1918
plt.close('all')
2019
pd.options.display.max_rows = 15
@@ -1767,7 +1766,7 @@ Note ``NaN``'s, ``NaT``'s and ``None`` will be converted to ``null`` and ``datet
17671766

17681767
.. ipython:: python
17691768
1770-
dfj = pd.DataFrame(randn(5, 2), columns=list('AB'))
1769+
dfj = pd.DataFrame(np.random.randn(5, 2), columns=list('AB'))
17711770
json = dfj.to_json()
17721771
json
17731772
@@ -1842,7 +1841,7 @@ Writing in ISO date format:
18421841

18431842
.. ipython:: python
18441843
1845-
dfd = pd.DataFrame(randn(5, 2), columns=list('AB'))
1844+
dfd = pd.DataFrame(np.random.randn(5, 2), columns=list('AB'))
18461845
dfd['date'] = pd.Timestamp('20130101')
18471846
dfd = dfd.sort_index(1, ascending=False)
18481847
json = dfd.to_json(date_format='iso')
@@ -2482,7 +2481,7 @@ Read in pandas ``to_html`` output (with some loss of floating point precision):
24822481

24832482
.. code-block:: python
24842483
2485-
df = pd.DataFrame(randn(2, 2))
2484+
df = pd.DataFrame(np.random.randn(2, 2))
24862485
s = df.to_html(float_format='{0:.40g}'.format)
24872486
dfin = pd.read_html(s, index_col=0)
24882487
@@ -2535,7 +2534,7 @@ in the method ``to_string`` described above.
25352534
25362535
.. ipython:: python
25372536
2538-
df = pd.DataFrame(randn(2, 2))
2537+
df = pd.DataFrame(np.random.randn(2, 2))
25392538
df
25402539
print(df.to_html()) # raw html
25412540
@@ -2611,7 +2610,7 @@ Finally, the ``escape`` argument allows you to control whether the
26112610

26122611
.. ipython:: python
26132612
2614-
df = pd.DataFrame({'a': list('&<>'), 'b': randn(3)})
2613+
df = pd.DataFrame({'a': list('&<>'), 'b': np.random.randn(3)})
26152614
26162615
26172616
.. ipython:: python
@@ -3187,7 +3186,7 @@ applications (CTRL-V on many operating systems). Here we illustrate writing a
31873186

31883187
.. ipython:: python
31893188
3190-
df = pd.DataFrame(randn(5, 3))
3189+
df = pd.DataFrame(np.random.randn(5, 3))
31913190
df
31923191
df.to_clipboard()
31933192
pd.read_clipboard()
@@ -3414,10 +3413,10 @@ dict:
34143413
.. ipython:: python
34153414
34163415
index = pd.date_range('1/1/2000', periods=8)
3417-
s = pd.Series(randn(5), index=['a', 'b', 'c', 'd', 'e'])
3418-
df = pd.DataFrame(randn(8, 3), index=index,
3416+
s = pd.Series(np.random.randn(5), index=['a', 'b', 'c', 'd', 'e'])
3417+
df = pd.DataFrame(np.random.randn(8, 3), index=index,
34193418
columns=['A', 'B', 'C'])
3420-
wp = pd.Panel(randn(2, 5, 4), items=['Item1', 'Item2'],
3419+
wp = pd.Panel(np.random.randn(2, 5, 4), items=['Item1', 'Item2'],
34213420
major_axis=pd.date_range('1/1/2000', periods=5),
34223421
minor_axis=['A', 'B', 'C', 'D'])
34233422
@@ -3563,7 +3562,7 @@ This format is specified by default when using ``put`` or ``to_hdf`` or by ``for
35633562

35643563
.. code-block:: python
35653564
3566-
>>> pd.DataFrame(randn(10, 2)).to_hdf('test_fixed.h5', 'df')
3565+
>>> pd.DataFrame(np.random.randn(10, 2)).to_hdf('test_fixed.h5', 'df')
35673566
>>> pd.read_hdf('test_fixed.h5', 'df', where='index>5')
35683567
TypeError: cannot pass a where specification when reading a fixed format.
35693568
this store must be selected in its entirety
@@ -3699,9 +3698,9 @@ defaults to `nan`.
36993698

37003699
.. ipython:: python
37013700
3702-
df_mixed = pd.DataFrame({'A': randn(8),
3703-
'B': randn(8),
3704-
'C': np.array(randn(8), dtype='float32'),
3701+
df_mixed = pd.DataFrame({'A': np.random.randn(8),
3702+
'B': np.random.randn(8),
3703+
'C': np.array(np.random.randn(8), dtype='float32'),
37053704
'string': 'string',
37063705
'int': 1,
37073706
'bool': True,
@@ -3841,7 +3840,7 @@ Here are some examples:
38413840

38423841
.. ipython:: python
38433842
3844-
dfq = pd.DataFrame(randn(10, 4), columns=list('ABCD'),
3843+
dfq = pd.DataFrame(np.random.randn(10, 4), columns=list('ABCD'),
38453844
index=pd.date_range('20130101', periods=10))
38463845
store.append('dfq', dfq, format='table', data_columns=True)
38473846
@@ -3946,8 +3945,8 @@ Oftentimes when appending large amounts of data to a store, it is useful to turn
39463945

39473946
.. ipython:: python
39483947
3949-
df_1 = pd.DataFrame(randn(10, 2), columns=list('AB'))
3950-
df_2 = pd.DataFrame(randn(10, 2), columns=list('AB'))
3948+
df_1 = pd.DataFrame(np.random.randn(10, 2), columns=list('AB'))
3949+
df_2 = pd.DataFrame(np.random.randn(10, 2), columns=list('AB'))
39513950
39523951
st = pd.HDFStore('appends.h5', mode='w')
39533952
st.append('df', df_1, data_columns=['B'], index=False)
@@ -4151,7 +4150,8 @@ results.
41514150

41524151
.. ipython:: python
41534152
4154-
df_mt = pd.DataFrame(randn(8, 6), index=pd.date_range('1/1/2000', periods=8),
4153+
df_mt = pd.DataFrame(np.random.randn(8, 6),
4154+
index=pd.date_range('1/1/2000', periods=8),
41554155
columns=['A', 'B', 'C', 'D', 'E', 'F'])
41564156
df_mt['foo'] = 'bar'
41574157
df_mt.loc[df_mt.index[1], ('A', 'B')] = np.nan
@@ -5181,7 +5181,7 @@ into a .dta file. The format version of this file is always 115 (Stata 12).
51815181

51825182
.. ipython:: python
51835183
5184-
df = pd.DataFrame(randn(10, 2), columns=list('AB'))
5184+
df = pd.DataFrame(np.random.randn(10, 2), columns=list('AB'))
51855185
df.to_stata('stata.dta')
51865186
51875187
*Stata* data files have limited data type support; only strings with
@@ -5405,7 +5405,7 @@ ignored.
54055405
.. code-block:: ipython
54065406
54075407
In [1]: sz = 1000000
5408-
In [2]: df = pd.DataFrame({'A': randn(sz), 'B': [1] * sz})
5408+
In [2]: df = pd.DataFrame({'A': np.random.randn(sz), 'B': [1] * sz})
54095409
54105410
In [3]: df.info()
54115411
<class 'pandas.core.frame.DataFrame'>

0 commit comments

Comments
 (0)