128
128
# goal is to be able to define the docs close to function, while still being
129
129
# able to share
130
130
_shared_docs = {** _shared_docs }
131
- _shared_doc_kwargs = dict (
132
- axes = "keywords for axes" ,
133
- klass = "Series/DataFrame" ,
134
- axes_single_arg = "int or labels for object" ,
135
- args_transpose = "axes to permute (int or label for object)" ,
136
- optional_by = """
131
+ _shared_doc_kwargs = {
132
+ " axes" : "keywords for axes" ,
133
+ " klass" : "Series/DataFrame" ,
134
+ " axes_single_arg" : "int or labels for object" ,
135
+ " args_transpose" : "axes to permute (int or label for object)" ,
136
+ " optional_by" : """
137
137
by : str or list of str
138
138
Name or list of names to sort by""" ,
139
- )
139
+ }
140
140
141
141
142
142
bool_t = bool # Need alias because NDFrame has def bool:
@@ -484,7 +484,7 @@ def _get_block_manager_axis(cls, axis: Axis) -> int:
484
484
def _get_axis_resolvers (self , axis : str ) -> Dict [str , Union [Series , MultiIndex ]]:
485
485
# index or columns
486
486
axis_index = getattr (self , axis )
487
- d = dict ()
487
+ d = {}
488
488
prefix = axis [0 ]
489
489
490
490
for i , name in enumerate (axis_index .names ):
@@ -1946,14 +1946,14 @@ def __array_ufunc__(
1946
1946
@final
1947
1947
def __getstate__ (self ) -> Dict [str , Any ]:
1948
1948
meta = {k : getattr (self , k , None ) for k in self ._metadata }
1949
- return dict (
1950
- _mgr = self ._mgr ,
1951
- _typ = self ._typ ,
1952
- _metadata = self ._metadata ,
1953
- attrs = self .attrs ,
1954
- _flags = {k : self .flags [k ] for k in self .flags ._keys },
1949
+ return {
1950
+ " _mgr" : self ._mgr ,
1951
+ " _typ" : self ._typ ,
1952
+ " _metadata" : self ._metadata ,
1953
+ " attrs" : self .attrs ,
1954
+ " _flags" : {k : self .flags [k ] for k in self .flags ._keys },
1955
1955
** meta ,
1956
- )
1956
+ }
1957
1957
1958
1958
@final
1959
1959
def __setstate__ (self , state ):
@@ -1967,7 +1967,7 @@ def __setstate__(self, state):
1967
1967
if typ is not None :
1968
1968
attrs = state .get ("_attrs" , {})
1969
1969
object .__setattr__ (self , "_attrs" , attrs )
1970
- flags = state .get ("_flags" , dict ( allows_duplicate_labels = True ) )
1970
+ flags = state .get ("_flags" , { " allows_duplicate_labels" : True } )
1971
1971
object .__setattr__ (self , "_flags" , Flags (self , ** flags ))
1972
1972
1973
1973
# set in the order of internal names
@@ -7422,7 +7422,7 @@ def isna(self: FrameOrSeries) -> FrameOrSeries:
7422
7422
7423
7423
>>> df = pd.DataFrame(dict(age=[5, 6, np.NaN],
7424
7424
... born=[pd.NaT, pd.Timestamp('1939-05-27'),
7425
- ... pd.Timestamp('1940-04-25')],
7425
+ ... pd.Timestamp('1940-04-25')],
7426
7426
... name=['Alfred', 'Batman', ''],
7427
7427
... toy=[None, 'Batmobile', 'Joker']))
7428
7428
>>> df
@@ -7489,7 +7489,7 @@ def notna(self: FrameOrSeries) -> FrameOrSeries:
7489
7489
7490
7490
>>> df = pd.DataFrame(dict(age=[5, 6, np.NaN],
7491
7491
... born=[pd.NaT, pd.Timestamp('1939-05-27'),
7492
- ... pd.Timestamp('1940-04-25')],
7492
+ ... pd.Timestamp('1940-04-25')],
7493
7493
... name=['Alfred', 'Batman', ''],
7494
7494
... toy=[None, 'Batmobile', 'Joker']))
7495
7495
>>> df
@@ -8209,8 +8209,8 @@ def resample(
8209
8209
For DataFrame objects, the keyword `on` can be used to specify the
8210
8210
column instead of the index for resampling.
8211
8211
8212
- >>> d = dict( {'price': [10, 11, 9, 13, 14, 18, 17, 19],
8213
- ... 'volume': [50, 60, 40, 100, 50, 100, 40, 50]})
8212
+ >>> d = {'price': [10, 11, 9, 13, 14, 18, 17, 19],
8213
+ ... 'volume': [50, 60, 40, 100, 50, 100, 40, 50]}
8214
8214
>>> df = pd.DataFrame(d)
8215
8215
>>> df['week_starting'] = pd.date_range('01/01/2018',
8216
8216
... periods=8,
@@ -8235,8 +8235,8 @@ def resample(
8235
8235
specify on which level the resampling needs to take place.
8236
8236
8237
8237
>>> days = pd.date_range('1/1/2000', periods=4, freq='D')
8238
- >>> d2 = dict( {'price': [10, 11, 9, 13, 14, 18, 17, 19],
8239
- ... 'volume': [50, 60, 40, 100, 50, 100, 40, 50]})
8238
+ >>> d2 = {'price': [10, 11, 9, 13, 14, 18, 17, 19],
8239
+ ... 'volume': [50, 60, 40, 100, 50, 100, 40, 50]}
8240
8240
>>> df2 = pd.DataFrame(d2,
8241
8241
... index=pd.MultiIndex.from_product([days,
8242
8242
... ['morning',
@@ -10483,10 +10483,10 @@ def pct_change(
10483
10483
Percentage change in French franc, Deutsche Mark, and Italian lira from
10484
10484
1980-01-01 to 1980-03-01.
10485
10485
10486
- >>> df = pd.DataFrame(dict(
10487
- ... FR= [4.0405, 4.0963, 4.3149],
10488
- ... GR= [1.7246, 1.7482, 1.8519],
10489
- ... IT= [804.74, 810.01, 860.13]) ,
10486
+ >>> df = pd.DataFrame({
10487
+ ... 'FR': [4.0405, 4.0963, 4.3149],
10488
+ ... 'GR': [1.7246, 1.7482, 1.8519],
10489
+ ... 'IT': [804.74, 810.01, 860.13]} ,
10490
10490
... index=['1980-01-01', '1980-02-01', '1980-03-01'])
10491
10491
>>> df
10492
10492
FR GR IT
@@ -10503,10 +10503,10 @@ def pct_change(
10503
10503
Percentage of change in GOOG and APPL stock volume. Shows computing
10504
10504
the percentage change between columns.
10505
10505
10506
- >>> df = pd.DataFrame(dict([
10507
- ... ( '2016', [1769950, 30586265]) ,
10508
- ... ( '2015', [1500923, 40912316]) ,
10509
- ... ( '2014', [1371819, 41403351])]) ,
10506
+ >>> df = pd.DataFrame({
10507
+ ... '2016': [1769950, 30586265],
10508
+ ... '2015': [1500923, 40912316],
10509
+ ... '2014': [1371819, 41403351]} ,
10510
10510
... index=['GOOG', 'APPL'])
10511
10511
>>> df
10512
10512
2016 2015 2014
0 commit comments