Skip to content

Commit 5bdec00

Browse files
martinagvilasAlexKirko
authored andcommitted
Fix EX03 errors (pandas-dev#30448)
1 parent 494c715 commit 5bdec00

File tree

1 file changed

+49
-48
lines changed

1 file changed

+49
-48
lines changed

pandas/core/generic.py

+49-48
Original file line numberDiff line numberDiff line change
@@ -790,7 +790,7 @@ def pop(self, item):
790790
>>> df = pd.DataFrame([('falcon', 'bird', 389.0),
791791
... ('parrot', 'bird', 24.0),
792792
... ('lion', 'mammal', 80.5),
793-
... ('monkey','mammal', np.nan)],
793+
... ('monkey', 'mammal', np.nan)],
794794
... columns=('name', 'class', 'max_speed'))
795795
>>> df
796796
name class max_speed
@@ -2785,12 +2785,12 @@ def to_xarray(self):
27852785
27862786
Examples
27872787
--------
2788-
>>> df = pd.DataFrame([('falcon', 'bird', 389.0, 2),
2788+
>>> df = pd.DataFrame([('falcon', 'bird', 389.0, 2),
27892789
... ('parrot', 'bird', 24.0, 2),
2790-
... ('lion', 'mammal', 80.5, 4),
2790+
... ('lion', 'mammal', 80.5, 4),
27912791
... ('monkey', 'mammal', np.nan, 4)],
2792-
... columns=['name', 'class', 'max_speed',
2793-
... 'num_legs'])
2792+
... columns=['name', 'class', 'max_speed',
2793+
... 'num_legs'])
27942794
>>> df
27952795
name class max_speed num_legs
27962796
0 falcon bird 389.0 2
@@ -2818,10 +2818,11 @@ class (index) object 'bird' 'bird' 'mammal' 'mammal'
28182818
>>> dates = pd.to_datetime(['2018-01-01', '2018-01-01',
28192819
... '2018-01-02', '2018-01-02'])
28202820
>>> df_multiindex = pd.DataFrame({'date': dates,
2821-
... 'animal': ['falcon', 'parrot', 'falcon',
2822-
... 'parrot'],
2823-
... 'speed': [350, 18, 361, 15]}).set_index(['date',
2824-
... 'animal'])
2821+
... 'animal': ['falcon', 'parrot',
2822+
... 'falcon', 'parrot'],
2823+
... 'speed': [350, 18, 361, 15]})
2824+
>>> df_multiindex = df_multiindex.set_index(['date', 'animal'])
2825+
28252826
>>> df_multiindex
28262827
speed
28272828
date animal
@@ -3307,12 +3308,12 @@ def take(self, indices, axis=0, is_copy: bool_t = True, **kwargs):
33073308
33083309
Examples
33093310
--------
3310-
>>> df = pd.DataFrame([('falcon', 'bird', 389.0),
3311-
... ('parrot', 'bird', 24.0),
3312-
... ('lion', 'mammal', 80.5),
3311+
>>> df = pd.DataFrame([('falcon', 'bird', 389.0),
3312+
... ('parrot', 'bird', 24.0),
3313+
... ('lion', 'mammal', 80.5),
33133314
... ('monkey', 'mammal', np.nan)],
3314-
... columns=['name', 'class', 'max_speed'],
3315-
... index=[0, 2, 3, 1])
3315+
... columns=['name', 'class', 'max_speed'],
3316+
... index=[0, 2, 3, 1])
33163317
>>> df
33173318
name class max_speed
33183319
0 falcon bird 389.0
@@ -3814,9 +3815,10 @@ def reindex_like(
38143815
... [31, 87.8, 'high'],
38153816
... [22, 71.6, 'medium'],
38163817
... [35, 95, 'medium']],
3817-
... columns=['temp_celsius', 'temp_fahrenheit', 'windspeed'],
3818-
... index=pd.date_range(start='2014-02-12',
3819-
... end='2014-02-15', freq='D'))
3818+
... columns=['temp_celsius', 'temp_fahrenheit',
3819+
... 'windspeed'],
3820+
... index=pd.date_range(start='2014-02-12',
3821+
... end='2014-02-15', freq='D'))
38203822
38213823
>>> df1
38223824
temp_celsius temp_fahrenheit windspeed
@@ -3828,9 +3830,9 @@ def reindex_like(
38283830
>>> df2 = pd.DataFrame([[28, 'low'],
38293831
... [30, 'low'],
38303832
... [35.1, 'medium']],
3831-
... columns=['temp_celsius', 'windspeed'],
3832-
... index=pd.DatetimeIndex(['2014-02-12', '2014-02-13',
3833-
... '2014-02-15']))
3833+
... columns=['temp_celsius', 'windspeed'],
3834+
... index=pd.DatetimeIndex(['2014-02-12', '2014-02-13',
3835+
... '2014-02-15']))
38343836
38353837
>>> df2
38363838
temp_celsius windspeed
@@ -4000,7 +4002,7 @@ def add_prefix(self, prefix: str):
40004002
item_3 4
40014003
dtype: int64
40024004
4003-
>>> df = pd.DataFrame({'A': [1, 2, 3, 4], 'B': [3, 4, 5, 6]})
4005+
>>> df = pd.DataFrame({'A': [1, 2, 3, 4], 'B': [3, 4, 5, 6]})
40044006
>>> df
40054007
A B
40064008
0 1 3
@@ -4059,7 +4061,7 @@ def add_suffix(self, suffix: str):
40594061
3_item 4
40604062
dtype: int64
40614063
4062-
>>> df = pd.DataFrame({'A': [1, 2, 3, 4], 'B': [3, 4, 5, 6]})
4064+
>>> df = pd.DataFrame({'A': [1, 2, 3, 4], 'B': [3, 4, 5, 6]})
40634065
>>> df
40644066
A B
40654067
0 1 3
@@ -4308,10 +4310,9 @@ def reindex(self, *args, **kwargs):
43084310
Create a dataframe with some fictional data.
43094311
43104312
>>> index = ['Firefox', 'Chrome', 'Safari', 'IE10', 'Konqueror']
4311-
>>> df = pd.DataFrame({
4312-
... 'http_status': [200,200,404,404,301],
4313-
... 'response_time': [0.04, 0.02, 0.07, 0.08, 1.0]},
4314-
... index=index)
4313+
>>> df = pd.DataFrame({'http_status': [200, 200, 404, 404, 301],
4314+
... 'response_time': [0.04, 0.02, 0.07, 0.08, 1.0]},
4315+
... index=index)
43154316
>>> df
43164317
http_status response_time
43174318
Firefox 200 0.04
@@ -4324,8 +4325,8 @@ def reindex(self, *args, **kwargs):
43244325
values in the new index that do not have corresponding
43254326
records in the dataframe are assigned ``NaN``.
43264327
4327-
>>> new_index= ['Safari', 'Iceweasel', 'Comodo Dragon', 'IE10',
4328-
... 'Chrome']
4328+
>>> new_index = ['Safari', 'Iceweasel', 'Comodo Dragon', 'IE10',
4329+
... 'Chrome']
43294330
>>> df.reindex(new_index)
43304331
http_status response_time
43314332
Safari 404.0 0.07
@@ -4677,7 +4678,7 @@ def head(self: FrameOrSeries, n: int = 5) -> FrameOrSeries:
46774678
46784679
Examples
46794680
--------
4680-
>>> df = pd.DataFrame({'animal':['alligator', 'bee', 'falcon', 'lion',
4681+
>>> df = pd.DataFrame({'animal': ['alligator', 'bee', 'falcon', 'lion',
46814682
... 'monkey', 'parrot', 'shark', 'whale', 'zebra']})
46824683
>>> df
46834684
animal
@@ -4736,7 +4737,7 @@ def tail(self: FrameOrSeries, n: int = 5) -> FrameOrSeries:
47364737
47374738
Examples
47384739
--------
4739-
>>> df = pd.DataFrame({'animal':['alligator', 'bee', 'falcon', 'lion',
4740+
>>> df = pd.DataFrame({'animal': ['alligator', 'bee', 'falcon', 'lion',
47404741
... 'monkey', 'parrot', 'shark', 'whale', 'zebra']})
47414742
>>> df
47424743
animal
@@ -8046,7 +8047,7 @@ def last(self, offset):
80468047
Examples
80478048
--------
80488049
>>> i = pd.date_range('2018-04-09', periods=4, freq='2D')
8049-
>>> ts = pd.DataFrame({'A': [1,2,3,4]}, index=i)
8050+
>>> ts = pd.DataFrame({'A': [1, 2, 3, 4]}, index=i)
80508051
>>> ts
80518052
A
80528053
2018-04-09 1
@@ -9025,7 +9026,7 @@ def truncate(
90259026
>>> df = pd.DataFrame({'A': ['a', 'b', 'c', 'd', 'e'],
90269027
... 'B': ['f', 'g', 'h', 'i', 'j'],
90279028
... 'C': ['k', 'l', 'm', 'n', 'o']},
9028-
... index=[1, 2, 3, 4, 5])
9029+
... index=[1, 2, 3, 4, 5])
90299030
>>> df
90309031
A B C
90319032
1 a f k
@@ -9266,22 +9267,22 @@ def tz_localize(
92669267
Localize local times:
92679268
92689269
>>> s = pd.Series([1],
9269-
... index=pd.DatetimeIndex(['2018-09-15 01:30:00']))
9270+
... index=pd.DatetimeIndex(['2018-09-15 01:30:00']))
92709271
>>> s.tz_localize('CET')
92719272
2018-09-15 01:30:00+02:00 1
92729273
dtype: int64
92739274
92749275
Be careful with DST changes. When there is sequential data, pandas
92759276
can infer the DST time:
92769277
9277-
>>> s = pd.Series(range(7), index=pd.DatetimeIndex([
9278-
... '2018-10-28 01:30:00',
9279-
... '2018-10-28 02:00:00',
9280-
... '2018-10-28 02:30:00',
9281-
... '2018-10-28 02:00:00',
9282-
... '2018-10-28 02:30:00',
9283-
... '2018-10-28 03:00:00',
9284-
... '2018-10-28 03:30:00']))
9278+
>>> s = pd.Series(range(7),
9279+
... index=pd.DatetimeIndex(['2018-10-28 01:30:00',
9280+
... '2018-10-28 02:00:00',
9281+
... '2018-10-28 02:30:00',
9282+
... '2018-10-28 02:00:00',
9283+
... '2018-10-28 02:30:00',
9284+
... '2018-10-28 03:00:00',
9285+
... '2018-10-28 03:30:00']))
92859286
>>> s.tz_localize('CET', ambiguous='infer')
92869287
2018-10-28 01:30:00+02:00 0
92879288
2018-10-28 02:00:00+02:00 1
@@ -9295,10 +9296,10 @@ def tz_localize(
92959296
In some cases, inferring the DST is impossible. In such cases, you can
92969297
pass an ndarray to the ambiguous parameter to set the DST explicitly
92979298
9298-
>>> s = pd.Series(range(3), index=pd.DatetimeIndex([
9299-
... '2018-10-28 01:20:00',
9300-
... '2018-10-28 02:36:00',
9301-
... '2018-10-28 03:46:00']))
9299+
>>> s = pd.Series(range(3),
9300+
... index=pd.DatetimeIndex(['2018-10-28 01:20:00',
9301+
... '2018-10-28 02:36:00',
9302+
... '2018-10-28 03:46:00']))
93029303
>>> s.tz_localize('CET', ambiguous=np.array([True, True, False]))
93039304
2018-10-28 01:20:00+02:00 0
93049305
2018-10-28 02:36:00+02:00 1
@@ -9308,9 +9309,9 @@ def tz_localize(
93089309
If the DST transition causes nonexistent times, you can shift these
93099310
dates forward or backwards with a timedelta object or `'shift_forward'`
93109311
or `'shift_backwards'`.
9311-
>>> s = pd.Series(range(2), index=pd.DatetimeIndex([
9312-
... '2015-03-29 02:30:00',
9313-
... '2015-03-29 03:30:00']))
9312+
>>> s = pd.Series(range(2),
9313+
... index=pd.DatetimeIndex(['2015-03-29 02:30:00',
9314+
... '2015-03-29 03:30:00']))
93149315
>>> s.tz_localize('Europe/Warsaw', nonexistent='shift_forward')
93159316
2015-03-29 03:00:00+02:00 0
93169317
2015-03-29 03:30:00+02:00 1

0 commit comments

Comments
 (0)