39
39
patch_pandas_sort , char_types , num_types )
40
40
from ..utils .keyword import dekeywordify
41
41
from .utils .params import ParamManager , ActionParamManager
42
- from .actions import format_params
43
42
44
43
# pylint: disable=W0212, W0221, W0613, R0904, C0330
45
44
@@ -415,7 +414,7 @@ def _get_plot_params(self, x=None, y=None, by=None, **kwargs):
415
414
Split parameters into fetch and plot parameter groups
416
415
417
416
'''
418
- params , kwargs = self ._get_sampling_params (** kwargs )
417
+ params , kwargs = self ._get_sampling_params (** kwargs )
419
418
params ['grouped' ] = True
420
419
params ['fetchvars' ] = self ._get_fetchvars (x = x , y = y , by = by )
421
420
return params , kwargs
@@ -543,7 +542,7 @@ def density(self, **kwargs):
543
542
return self ._table ._fetch (** params ).plot .density (** kwargs )
544
543
545
544
def hexbin (self , x = None , y = None , C = None , reduce_C_function = None ,
546
- gridsize = None , ** kwargs ):
545
+ gridsize = None , ** kwargs ):
547
546
'''
548
547
Hexbin plot
549
548
@@ -562,8 +561,10 @@ def hexbin(self, x=None, y=None, C=None, reduce_C_function=None,
562
561
563
562
'''
564
563
params , kwargs = self ._get_plot_params (x = x , y = y , ** kwargs )
565
- return self ._table ._fetch (** params ).plot .hexbin (x = x , y = y , C = C ,
566
- reduce_C_function = reduce_C_function , gridsize = gridsize , ** kwargs )
564
+ return self ._table ._fetch (** params )\
565
+ .plot .hexbin (x = x , y = y , C = C ,
566
+ reduce_C_function = reduce_C_function ,
567
+ gridsize = gridsize , ** kwargs )
567
568
568
569
def hist (self , by = None , bins = 10 , ** kwargs ):
569
570
'''
@@ -1175,9 +1176,6 @@ def _bootstrap(cls, connection):
1175
1176
1176
1177
'''
1177
1178
if not cls .table_params or not cls .outtable_params :
1178
- tblparams = 'Unknown'
1179
- outtblparams = 'Unknown'
1180
-
1181
1179
param_names = []
1182
1180
1183
1181
actinfo = connection ._get_action_info ('builtins.cascommon' )
@@ -1187,18 +1185,12 @@ def _bootstrap(cls, connection):
1187
1185
# Populate valid fields for tables and outtables
1188
1186
if item ['name' ] == 'castable' :
1189
1187
cls .table_params = set ([x ['name' ] for x in item ['parmList' ]])
1190
- tblparams = format_params (item ['parmList' ], connection ,
1191
- param_names = param_names ).rstrip ()
1192
1188
1193
1189
elif item ['name' ] == 'casouttable' :
1194
1190
cls .outtable_params = set ([x ['name' ] for x in item ['parmList' ]])
1195
- outtblparams = format_params (item ['parmList' ], connection ,
1196
- param_names = param_names ).rstrip ()
1197
1191
1198
1192
elif item ['name' ] == 'casouttablebasic' :
1199
1193
cls .outtable_params = set ([x ['name' ] for x in item ['parmList' ]])
1200
- outtblparams = format_params (item ['parmList' ], connection ,
1201
- param_names = param_names ).rstrip ()
1202
1194
1203
1195
for name in list (param_names ):
1204
1196
if keyword .iskeyword (name ):
@@ -3079,8 +3071,8 @@ def describe(self, percentiles=None, include=None, exclude=None, stats=None):
3079
3071
if not numrows :
3080
3072
return pd .DataFrame ([[0 ] * len (tbl .columns ),
3081
3073
[0 ] * len (tbl .columns )],
3082
- index = ['count' , 'unique' ],
3083
- columns = tbl .columns )
3074
+ index = ['count' , 'unique' ],
3075
+ columns = tbl .columns )
3084
3076
3085
3077
# Get percentiles
3086
3078
if percentiles is not None :
@@ -3277,8 +3269,6 @@ def _topk_values(self, stats=['unique', 'min', 'max'], axis=None, skipna=True,
3277
3269
:class:`pandas.DataFrame`
3278
3270
3279
3271
'''
3280
- from ..dataframe import reshape_bygroups
3281
-
3282
3272
if numeric_only :
3283
3273
inputs = self ._get_dtypes (include = 'numeric' )
3284
3274
else :
@@ -4008,13 +3998,13 @@ def drop(self, labels, axis=0, level=None, inplace=False, errors='raise'):
4008
3998
# raise NotImplementedError
4009
3999
4010
4000
def reset_index (self , level = None , drop = False , inplace = False ,
4011
- col_level = 0 , col_fill = '' , ** kwargs ):
4001
+ col_level = 0 , col_fill = '' , ** kwargs ):
4012
4002
'''
4013
4003
Reset the CASTable index
4014
4004
4015
4005
NOTE: CAS tables do not support indexing, so this method
4016
4006
just returns self (if inplace=True), or a copy of
4017
- self (if inplace=False) simply for DataFrame
4007
+ self (if inplace=False) simply for DataFrame
4018
4008
compatibility.
4019
4009
4020
4010
Returns
@@ -4027,7 +4017,7 @@ def reset_index(self, level=None, drop=False, inplace=False,
4027
4017
return copy .deepcopy (self )
4028
4018
4029
4019
def sample (self , n = None , frac = None , replace = False , weights = None ,
4030
- random_state = None , axis = None , stratify_by = None , ** kwargs ):
4020
+ random_state = None , axis = None , stratify_by = None , ** kwargs ):
4031
4021
'''
4032
4022
Returns a random sample of the CAS table rows
4033
4023
@@ -4368,7 +4358,8 @@ def to_re_sub(patt, to):
4368
4358
if not isinstance (patt , char_types ):
4369
4359
raise TypeError ('Regular expression pattern is not a string: %s' % patt )
4370
4360
if not isinstance (to , char_types ):
4371
- raise TypeError ('Regular expression substitution is not a string: %s' % to )
4361
+ raise TypeError ('Regular expression substitution is not a string: %s'
4362
+ % to )
4372
4363
to = re .sub (r'\\(\d)' , r'$\1' , to )
4373
4364
return _quote ('s/%s/%s/%s' % (patt , to , flags ))
4374
4365
@@ -4464,7 +4455,8 @@ def _apply_datastep(self, code, inplace=False, casout=None):
4464
4455
4465
4456
dscode = []
4466
4457
dscode .append ('data %s(caslib=%s);' % (_quote (newname ), _quote (caslib )))
4467
- dscode .append (' set %s(caslib=%s);' % (_quote (self .params .name ), _quote (caslib )))
4458
+ dscode .append (' set %s(caslib=%s);' % (_quote (self .params .name ),
4459
+ _quote (caslib )))
4468
4460
if isinstance (code , items_types ):
4469
4461
dscode .extend (code )
4470
4462
else :
@@ -4650,7 +4642,7 @@ def to_view(self, *args, **kwargs):
4650
4642
# raise NotImplementedError
4651
4643
4652
4644
def _fetch (self , grouped = False , sample_pct = None , sample_seed = None ,
4653
- stratify_by = None , sample = False , ** kwargs ):
4645
+ stratify_by = None , sample = False , ** kwargs ):
4654
4646
'''
4655
4647
Return the fetched DataFrame given the fetch parameters
4656
4648
@@ -4710,7 +4702,7 @@ def _fetch(self, grouped=False, sample_pct=None, sample_seed=None,
4710
4702
4711
4703
# Add grouping columns if they aren't in the list
4712
4704
columns = None
4713
- if groups and 'fetchvars' in kwargs :
4705
+ if groups and 'fetchvars' in kwargs :
4714
4706
kwargs ['fetchvars' ] = list (kwargs ['fetchvars' ])
4715
4707
for group in reversed (groups ):
4716
4708
if group not in kwargs ['fetchvars' ]:
@@ -4724,7 +4716,8 @@ def _fetch(self, grouped=False, sample_pct=None, sample_seed=None,
4724
4716
4725
4717
# Sort based on 'Fetch#' key. This will be out of order in REST.
4726
4718
values = [x [1 ] for x in sorted (tbl ._retrieve ('table.fetch' , ** kwargs ).items (),
4727
- key = lambda x : int (x [0 ].replace ('Fetch' , '' ) or '0' ))]
4719
+ key = lambda x : int (x [0 ].replace ('Fetch' , '' ) or
4720
+ '0' ))]
4728
4721
out = df .concat (values )
4729
4722
4730
4723
if tbl is not self :
@@ -4786,7 +4779,7 @@ def _sample(self, sample_pct=None, sample_seed=None, stratify_by=None, columns=N
4786
4779
return out
4787
4780
4788
4781
def _fetchall (self , grouped = False , sample_pct = None , sample_seed = None ,
4789
- sample = False , stratify_by = None , ** kwargs ):
4782
+ sample = False , stratify_by = None , ** kwargs ):
4790
4783
''' Fetch all rows '''
4791
4784
kwargs = kwargs .copy ()
4792
4785
if 'to' not in kwargs :
@@ -4940,7 +4933,7 @@ def _from_any(cls, name, connection, data, **kwargs):
4940
4933
if 'table' in table :
4941
4934
table ['name' ] = table .pop ('table' )
4942
4935
return connection .upload_frame (dframe , casout = table and table or None )
4943
- # importoptions=connection._importoptions_from_dframe(dframe)
4936
+ # importoptions=connection._importoptions_from_dframe(dframe)
4944
4937
dmh = PandasDataFrame (dframe )
4945
4938
table .update (dmh .args .addtable )
4946
4939
return connection .retrieve ('table.addtable' , ** table )['casTable' ]
@@ -5129,7 +5122,7 @@ def info(self, verbose=None, buf=None, max_cols=None,
5129
5122
buf .write (u'memory usage: %s\n ' % details ['AllocatedMemory' ])
5130
5123
5131
5124
def to_frame (self , sample_pct = None , sample_seed = None , sample = False ,
5132
- stratify_by = None , ** kwargs ):
5125
+ stratify_by = None , ** kwargs ):
5133
5126
'''
5134
5127
Retrieve entire table as a :class:`SASDataFrame`
5135
5128
@@ -5175,7 +5168,7 @@ def _to_any(self, method, *args, **kwargs):
5175
5168
params ['stratify_by' ] = kwargs .pop ('stratify_by' , None )
5176
5169
params ['to' ] = kwargs .pop ('to' , None )
5177
5170
params ['from' ] = kwargs .pop ('from' , kwargs .pop ('from_' , None ))
5178
- params = {k :v for k , v in params .items () if v is not None }
5171
+ params = {k : v for k , v in params .items () if v is not None }
5179
5172
standard_dataframe = kwargs .pop ('standard_dataframe' , False )
5180
5173
dframe = self ._fetch (** params )
5181
5174
if standard_dataframe :
@@ -7574,7 +7567,7 @@ def _compute(self, funcname, code, use_quotes=True, extra_computedvars=None,
7574
7567
if eval_values and isinstance (item , (CASColumn , pd .Series )):
7575
7568
for subitem in item .unique ().tolist ():
7576
7569
if isinstance (subitem , text_types ) or \
7577
- isinstance (subitem , binary_types ):
7570
+ isinstance (subitem , binary_types ):
7578
7571
items .append ('"%s"' % _escape_string (subitem ))
7579
7572
else :
7580
7573
items .append (str (subitem ))
0 commit comments