8000 DOC: Changed import statements in examples in docstrings (#21774) · pandas-dev/pandas@3091755 · GitHub
[go: up one dir, main page]

10000 Skip to content

Commit 3091755

Browse files
alphaCTzo7Gjorisvandenbossche
authored andcommitted
DOC: Changed import statements in examples in docstrings (#21774)
1 parent 4c98f30 commit 3091755

File tree

15 files changed

+20
-51
lines changed

15 files changed

+20
-51
lines changed

pandas/core/frame.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5655,7 +5655,6 @@ def unstack(self, level=-1, fill_value=None):
56555655
56565656
Examples
56575657
--------
5658-
>>> import pandas as pd
56595658
>>> df = pd.DataFrame({'A': {0: 'a', 1: 'b', 2: 'c'},
56605659
... 'B': {0: 1, 1: 3, 2: 5},
56615660
... 'C': {0: 2, 1: 4, 2: 6}})

pandas/core/generic.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4914,7 +4914,6 @@ def ftypes(self):
49144914
49154915
Examples
49164916
--------
4917-
>>> import numpy as np
49184917
>>> arr = np.random.RandomState(0).randn(100, 4)
49194918
>>> arr[arr < .8] = np.nan
49204919
>>> pd.DataFrame(arr).ftypes

pandas/core/groupby/groupby.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3694,7 +3694,6 @@ def filter(self, func, dropna=True, *args, **kwargs): # noqa
36943694
36953695
Examples
36963696
--------
3697-
>>> import pandas as pd
36983697
>>> df = pd.DataFrame({'A' : ['foo', 'bar', 'foo', 'bar',
36993698
... 'foo', 'bar'],
37003699
... 'B' : [1, 2, 3, 4, 5, 6],
@@ -4528,7 +4527,6 @@ def filter(self, func, dropna=True, *args, **kwargs): # noqa
45284527
45294528
Examples
45304529
--------
4531-
>>> import pandas as pd
45324530
>>> df = pd.DataFrame({'A' : ['foo', 'bar', 'foo', 'bar',
45334531
... 'foo', 'bar'],
45344532
... 'B' : [1, 2, 3, 4, 5, 6],

pandas/core/panel.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@ def panel_index(time, panels, names=None):
8989
9090
or
9191
92-
>>> import numpy as np
9392
>>> years = np.repeat(range(1960,1963), 3)
9493
>>> panels = np.tile(['A', 'B', 'C'], 3)
9594
>>> panel_idx = panel_index(years, panels)

pandas/core/reshape/melt.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@ def lreshape(data, groups, dropna=True, label=None):
103103
104104
Examples
105105
--------
106-
>>> import pandas as pd
107106
>>> data = pd.DataFrame({'hr1': [514, 573], 'hr2': [545, 526],
108107
... 'team': ['Red Sox', 'Yankees'],
109108
... 'year1': [2007, 2007], 'year2': [2008, 2008]})
@@ -217,8 +216,6 @@ def wide_to_long(df, stubnames, i, j, sep="", suffix=r'\d+'):
217216
218217
Examples
219218
--------
220-
>>> import pandas as pd
221-
>>> import numpy as np
222219
>>> np.random.seed(123)
223220
>>> df = pd.DataFrame({"A1970" : {0 : "a", 1 : "b", 2 : "c"},
224221
... "A1980" : {0 : "d", 1 : "e", 2 : "f"},

pandas/core/reshape/reshape.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ class _Unstacker(object):
5858
5959
Examples
6060
--------
61-
>>> import pandas as pd
6261
>>> index = pd.MultiIndex.from_tuples([('one', 'a'), ('one', 'b'),
6362
... ('two', 'a'), ('two', 'b')])
6463
>>> s = pd.Series(np.arange(1, 5, dtype=np.int64), index=index)
@@ -771,7 +770,6 @@ def get_dummies(data, prefix=None, prefix_sep='_', dummy_na=False,
771770
772771
Examples
773772
--------
774-
>>> import pandas as pd
775773
>>> s = pd.Series(list('abca'))
776774
777775
>>> pd.get_dummies(s)

pandas/core/series.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2749,8 +2749,6 @@ def nlargest(self, n=5, keep='first'):
27492749
27502750
Examples
27512751
--------
2752-
>>> import pandas as pd
2753-
>>> import numpy as np
27542752
>>> s = pd.Series(np.random.randn(10**6))
27552753
>>> s.nlargest(10) # only sorts up to the N requested
27562754
219921 4.644710
@@ -2796,8 +2794,6 @@ def nsmallest(self, n=5, keep='first'):
27962794
27972795
Examples
27982796
--------
2799-
>>> import pandas as pd
2800-
>>> import numpy as np
28012797
>>> s = pd.Series(np.random.randn(10**6))
28022798
>>> s.nsmallest(10) # only sorts up to the N requested
28032799
288532 -4.954580
@@ -3048,7 +3044,7 @@ def _gotitem(self, key, ndim, subset=None):
30483044
Examples
30493045
--------
30503046
3051-
>>> s = Series(np.random.randn(10))
3047+
>>> s = pd.Series(np.random.randn(10))
30523048
30533049
>>> s.agg('min')
30543050
-1.3018049988556679
@@ -3127,8 +3123,6 @@ def apply(self, func, convert_dtype=True, args=(), **kwds):
31273123
31283124
Create a series with typical summer temperatures for each city.
31293125
3130-
>>> import pandas as pd
3131-
>>> import numpy as np
31323126
>>> series = pd.Series([20, 21, 12], index=['London',
31333127
... 'New York','Helsinki'])
31343128
>>> series

pandas/core/sparse/series.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -736,15 +736,14 @@ def to_coo(self, row_levels=(0, ), column_levels=(1, ), sort_labels=False):
736736
737737
Examples
738738
--------
739-
>>> from numpy import nan
740-
>>> s = Series([3.0, nan, 1.0, 3.0, nan, nan])
741-
>>> s.index = MultiIndex.from_tuples([(1, 2, 'a', 0),
742-
(1, 2, 'a', 1),
743-
(1, 1, 'b', 0),
744-
(1, 1, 'b', 1),
745-
(2, 1, 'b', 0),
746-
(2, 1, 'b', 1)],
747-
names=['A', 'B', 'C', 'D'])
739+
>>> s = pd.Series([3.0, np.nan, 1.0, 3.0, np.nan, np.nan])
740+
>>> s.index = pd.MultiIndex.from_tuples([(1, 2, 'a', 0),
741+
(1, 2, 'a', 1),
742+
(1, 1, 'b', 0),
743+
(1, 1, 'b', 1),
744+
(2, 1, 'b', 0),
745+
(2, 1, 'b', 1)],
746+
names=['A', 'B', 'C', 'D'])
748747
>>> ss = s.to_sparse()
749748
>>> A, rows, columns = ss.to_coo(row_levels=['A', 'B'],
750749
column_levels=['C', 'D'],

pandas/core/tools/numeric.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ def to_numeric(arg, errors='raise', downcast=None):
5858
--------
5959
Take separate series and convert to numeric, coercing when told to
6060
61-
>>> import pandas as pd
6261
>>> s = pd.Series(['1.0', '2', -3])
6362
>>> pd.to_numeric(s)
6463
0 1.0

pandas/io/pytables.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -454,9 +454,7 @@ class HDFStore(StringMixin):
454454
455455
Examples
456456
--------
457-
>>> from pandas import DataFrame
458-
>>> from numpy.random import randn
459-
>>> bar = DataFrame(randn(10, 4))
457+
>>> bar = pd.DataFrame(np.random.randn(10, 4))
460458
>>> store = HDFStore('test.h5')
461459
>>> store['foo'] = bar # write to HDF5
462460
>>> bar = store['foo'] # retrieve

0 commit comments

Comments
 (0)
0