Skip to content

Commit 5b132d0

Browse files
alphaCTzo7Gvictor
authored and
victor
committed
DOC: Changed import statements in examples in docstrings (pandas-dev#21774)
1 parent e755520 commit 5b132d0

File tree

15 files changed

+20
-51
lines changed

15 files changed

+20
-51
lines changed

pandas/core/frame.py

-1
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

-1
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

-2
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

-1
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

-3
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

-2
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

+1-7
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

+8-9
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

-1
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

+1-3
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

pandas/io/sas/sas_xport.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,11 @@
6868
--------
6969
Read a SAS Xport file:
7070
71-
>>> df = pandas.read_sas('filename.XPT')
71+
>>> df = pd.read_sas('filename.XPT')
7272
7373
Read a Xport file in 10,000 line chunks:
7474
75-
>>> itr = pandas.read_sas('filename.XPT', chunksize=10000)
75+
>>> itr = pd.read_sas('filename.XPT', chunksize=10000)
7676
>>> for chunk in itr:
7777
>>> do_something(chunk)
7878

pandas/io/stata.py

-4
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,6 @@
102102
--------
103103
Read a Stata dta file:
104104
105-
>>> import pandas as pd
106105
>>> df = pd.read_stata('filename.dta')
107106
108107
Read a Stata dta file in 10,000 line chunks:
@@ -216,7 +215,6 @@ def _stata_elapsed_date_to_datetime_vec(dates, fmt):
216215
217216
Examples
218217
--------
219-
>>> import pandas as pd
220218
>>> dates = pd.Series([52])
221219
>>> _stata_elapsed_date_to_datetime_vec(dates , "%tw")
222220
0 1961-01-01
@@ -1946,7 +1944,6 @@ class StataWriter(StataParser):
19461944
19471945
Examples
19481946
--------
1949-
>>> import pandas as pd
19501947
>>> data = pd.DataFrame([[1.0, 1]], columns=['a', 'b'])
19511948
>>> writer = StataWriter('./data_file.dta', data)
19521949
>>> writer.write_file()
@@ -2709,7 +2706,6 @@ class StataWriter117(StataWriter):
27092706
27102707
Examples
27112708
--------
2712-
>>> import pandas as pd
27132709
>>> from pandas.io.stata import StataWriter117
27142710
>>> data = pd.DataFrame([[1.0, 1, 'a']], columns=['a', 'b', 'c'])
27152711
>>> writer = StataWriter117('./data_file.dta', data)

pandas/plotting/_core.py

+2-5
Original file line numberDiff line numberDiff line change
@@ -2609,14 +2609,11 @@ def boxplot_frame_groupby(grouped, subplots=True, column=None, fontsize=None,
26092609
26102610
Examples
26112611
--------
2612-
>>> import pandas
2613-
>>> import numpy as np
26142612
>>> import itertools
2615-
>>>
26162613
>>> tuples = [t for t in itertools.product(range(1000), range(4))]
2617-
>>> index = pandas.MultiIndex.from_tuples(tuples, names=['lvl0', 'lvl1'])
2614+
>>> index = pd.MultiIndex.from_tuples(tuples, names=['lvl0', 'lvl1'])
26182615
>>> data = np.random.randn(len(index),4)
2619-
>>> df = pandas.DataFrame(data, columns=list('ABCD'), index=index)
2616+
>>> df = pd.DataFrame(data, columns=list('ABCD'), index=index)
26202617
>>>
26212618
>>> grouped = df.groupby(level='lvl1')
26222619
>>> boxplot_frame_groupby(grouped)

pandas/plotting/_misc.py

+4-7
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,6 @@ def bootstrap_plot(series, fig=None, size=50, samples=500, **kwds):
406406
.. plot::
407407
:context: close-figs
408408
409-
>>> import numpy as np
410409
>>> s = pd.Series(np.random.uniform(size=100))
411410
>>> fig = pd.plotting.bootstrap_plot(s)
412411
"""
@@ -498,13 +497,11 @@ def parallel_coordinates(frame, class_column, cols=None, ax=None, color=None,
498497
499498
Examples
500499
--------
501-
>>> from pandas import read_csv
502-
>>> from pandas.tools.plotting import parallel_coordinates
503500
>>> from matplotlib import pyplot as plt
504-
>>> df = read_csv('https://raw.github.com/pandas-dev/pandas/master'
505-
'/pandas/tests/data/iris.csv')
506-
>>> parallel_coordinates(df, 'Name', color=('#556270',
507-
'#4ECDC4', '#C7F464'))
501+
>>> df = pd.read_csv('https://raw.github.com/pandas-dev/pandas/master'
502+
'/pandas/tests/data/iris.csv')
503+
>>> pd.plotting.parallel_coordinates(df, 'Name',
504+
color=('#556270', '#4ECDC4', '#C7F464'))
508505
>>> plt.show()
509506
"""
510507
if axvlines_kwds is None:

pandas/tseries/holiday.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -143,12 +143,11 @@ class from pandas.tseries.offsets
143143
Examples
144144
--------
145145
>>> from pandas.tseries.holiday import Holiday, nearest_workday
146-
>>> from pandas import DateOffset
147146
>>> from dateutil.relativedelta import MO
148147
>>> USMemorialDay = Holiday('MemorialDay', month=5, day=24,
149-
offset=DateOffset(weekday=MO(1)))
148+
offset=pd.DateOffset(weekday=MO(1)))
150149
>>> USLaborDay = Holiday('Labor Day', month=9, day=1,
151-
offset=DateOffset(weekday=MO(1)))
150+
offset=pd.DateOffset(weekday=MO(1)))
152151
>>> July3rd = Holiday('July 3rd', month=7, day=3,)
153152
>>> NewYears = Holiday('New Years Day', month=1, day=1,
154153
observance=nearest_workday),

0 commit comments

Comments
 (0)