idx
int64
0
63k
question
stringlengths
61
4.03k
target
stringlengths
6
1.23k
34,000
def academic_degree ( self ) -> str : degrees = self . _data [ 'academic_degree' ] return self . random . choice ( degrees )
Get a random academic degree .
34,001
def language ( self ) -> str : languages = self . _data [ 'language' ] return self . random . choice ( languages )
Get a random language .
34,002
def telephone ( self , mask : str = '' , placeholder : str = '#' ) -> str : if not mask : code = self . random . choice ( CALLING_CODES ) default = '{}-(###)-###-####' . format ( code ) masks = self . _data . get ( 'telephone_fmt' , [ default ] ) mask = self . random . choice ( masks ) return self . random . custom_cod...
Generate a random phone number .
34,003
def avatar ( self , size : int = 256 ) -> str : url = 'https://api.adorable.io/avatars/{0}/{1}.png' return url . format ( size , self . password ( hashed = True ) )
Generate a random avatar ..
34,004
def identifier ( self , mask : str = '##-##/##' ) -> str : return self . random . custom_code ( mask = mask )
Generate a random identifier by mask .
34,005
def custom_size ( self , minimum : int = 40 , maximum : int = 62 ) -> int : return self . random . randint ( minimum , maximum )
Generate clothing size using custom format .
34,006
def luhn_checksum ( num : str ) -> str : check = 0 for i , s in enumerate ( reversed ( num ) ) : sx = int ( s ) sx = sx * 2 if i % 2 == 0 else sx sx = sx - 9 if sx > 9 else sx check += sx return str ( check * 9 % 10 )
Calculate a checksum for num using the Luhn algorithm .
34,007
def download_image ( url : str = '' , save_path : str = '' , unverified_ctx : bool = False ) -> Union [ None , str ] : if unverified_ctx : ssl . _create_default_https_context = ssl . _create_unverified_context if url : image_name = url . rsplit ( '/' ) [ - 1 ] splitted_name = image_name . rsplit ( '.' ) if len ( splitt...
Download image and save in current directory on local machine .
34,008
def nip ( self ) -> str : nip_digits = [ int ( d ) for d in str ( self . random . randint ( 101 , 998 ) ) ] nip_digits += [ self . random . randint ( 0 , 9 ) for _ in range ( 6 ) ] nip_coefficients = ( 6 , 5 , 7 , 2 , 3 , 4 , 5 , 6 , 7 ) sum_v = sum ( [ nc * nd for nc , nd in zip ( nip_coefficients , nip_digits ) ] ) c...
Generate random valid 10 - digit NIP .
34,009
def pesel ( self , birth_date : DateTime = None , gender : Gender = None ) -> str : date_object = birth_date if not date_object : date_object = Datetime ( ) . datetime ( 1940 , 2018 ) year = date_object . date ( ) . year month = date_object . date ( ) . month day = date_object . date ( ) . day pesel_digits = [ int ( d ...
Generate random 11 - digit PESEL .
34,010
def regon ( self ) -> str : regon_coeffs = ( 8 , 9 , 2 , 3 , 4 , 5 , 6 , 7 ) regon_digits = [ self . random . randint ( 0 , 9 ) for _ in range ( 8 ) ] sum_v = sum ( [ nc * nd for nc , nd in zip ( regon_coeffs , regon_digits ) ] ) checksum_digit = sum_v % 11 if checksum_digit > 9 : checksum_digit = 0 regon_digits . appe...
Generate random valid 9 - digit REGON .
34,011
def tracking_number ( self , service : str = 'usps' ) -> str : service = service . lower ( ) if service not in ( 'usps' , 'fedex' , 'ups' ) : raise ValueError ( 'Unsupported post service' ) services = { 'usps' : ( '#### #### #### #### ####' , '@@ ### ### ### US' , ) , 'fedex' : ( '#### #### ####' , '#### #### #### ###'...
Generate random tracking number .
34,012
def ssn ( self ) -> str : area = self . random . randint ( 1 , 899 ) if area == 666 : area = 665 return '{:03}-{:02}-{:04}' . format ( area , self . random . randint ( 1 , 99 ) , self . random . randint ( 1 , 9999 ) , )
Generate a random but valid SSN .
34,013
def personality ( self , category : str = 'mbti' ) -> Union [ str , int ] : mbtis = ( 'ISFJ' , 'ISTJ' , 'INFJ' , 'INTJ' , 'ISTP' , 'ISFP' , 'INFP' , 'INTP' , 'ESTP' , 'ESFP' , 'ENFP' , 'ENTP' , 'ESTJ' , 'ESFJ' , 'ENFJ' , 'ENTJ' ) if category . lower ( ) == 'rheti' : return self . random . randint ( 1 , 10 ) return self...
Generate a type of personality .
34,014
def unit ( self , name : Optional [ UnitName ] = None , symbol = False ) : result = self . _validate_enum ( item = name , enum = UnitName ) if symbol : return result [ 1 ] return result [ 0 ]
Get unit name .
34,015
def prefix ( self , sign : Optional [ PrefixSign ] = None , symbol : bool = False ) -> str : prefixes = SI_PREFIXES_SYM if symbol else SI_PREFIXES key = self . _validate_enum ( item = sign , enum = PrefixSign ) return self . random . choice ( prefixes [ key ] )
Get a random prefix for the International System of Units .
34,016
def bsn ( self ) -> str : def _is_valid_bsn ( number : str ) -> bool : total = 0 multiplier = 9 for char in number : multiplier = - multiplier if multiplier == 1 else multiplier total += int ( char ) * multiplier multiplier -= 1 result = total % 11 == 0 return result a , b = ( 100000000 , 999999999 ) sample = str ( sel...
Generate a random but valid Burgerservicenummer .
34,017
def create ( self , iterations : int = 1 ) -> List [ JSON ] : return [ self . schema ( ) for _ in range ( iterations ) ]
Return filled schema .
34,018
def reseed ( self , seed : Seed = None ) -> None : if self . random is random : self . random = Random ( ) self . seed = seed self . random . seed ( self . seed )
Reseed the internal random generator .
34,019
def _validate_enum ( self , item : Any , enum : Any ) -> Any : if item is None : result = get_random_item ( enum , self . random ) elif item and isinstance ( item , enum ) : result = item else : raise NonEnumerableError ( enum ) return result . value
Validate enum parameter of method in subclasses of BaseProvider .
34,020
def _setup_locale ( self , locale : str = locales . DEFAULT_LOCALE ) -> None : if not locale : locale = locales . DEFAULT_LOCALE locale = locale . lower ( ) if locale not in locales . SUPPORTED_LOCALES : raise UnsupportedLocale ( locale ) self . locale = locale
Set up locale after pre - check .
34,021
def _update_dict ( self , initial : JSON , other : Mapping ) -> JSON : for key , value in other . items ( ) : if isinstance ( value , collections . Mapping ) : r = self . _update_dict ( initial . get ( key , { } ) , value ) initial [ key ] = r else : initial [ key ] = other [ key ] return initial
Recursively update a dictionary .
34,022
def pull ( self , datafile : str = '' ) : locale = self . locale data_dir = self . _data_dir if not datafile : datafile = self . _datafile def get_data ( locale_name : str ) -> JSON : file_path = Path ( data_dir ) . joinpath ( locale_name , datafile ) with open ( file_path , 'r' , encoding = 'utf8' ) as f : return json...
Pull the content from the JSON and memorize one .
34,023
def _override_locale ( self , locale : str = locales . DEFAULT_LOCALE ) -> None : self . locale = locale self . pull . cache_clear ( ) self . pull ( )
Overrides current locale with passed and pull data for new locale .
34,024
def street_number ( self , maximum : int = 1400 ) -> str : return str ( self . random . randint ( 1 , maximum ) )
Generate a random street number .
34,025
def address ( self ) -> str : fmt = self . _data [ 'address_fmt' ] st_num = self . street_number ( ) st_name = self . street_name ( ) if self . locale in SHORTENED_ADDRESS_FMT : return fmt . format ( st_num = st_num , st_name = st_name , ) if self . locale == 'ja' : return fmt . format ( self . random . choice ( self ....
Generate a random full address .
34,026
def state ( self , abbr : bool = False ) -> str : return self . random . choice ( self . _data [ 'state' ] [ 'abbr' if abbr else 'name' ] )
Get a random administrative district of country .
34,027
def country_code ( self , fmt : Optional [ CountryCode ] = CountryCode . A2 ) -> str : key = self . _validate_enum ( fmt , CountryCode ) return self . random . choice ( COUNTRY_CODES [ key ] )
Get a random code of country .
34,028
def _get_fs ( self , key : str , dms : bool = False ) -> Union [ str , float ] : rng = ( - 90 , 90 ) if key == 'lt' else ( - 180 , 180 ) result = self . random . uniform ( * rng , precision = 6 ) if dms : return self . _dd_to_dms ( result , key ) return result
Get float number .
34,029
def latitude ( self , dms : bool = False ) -> Union [ str , float ] : return self . _get_fs ( 'lt' , dms )
Generate a random value of latitude .
34,030
def coordinates ( self , dms : bool = False ) -> dict : return { 'longitude' : self . _get_fs ( 'lg' , dms ) , 'latitude' : self . _get_fs ( 'lt' , dms ) , }
Generate random geo coordinates .
34,031
def continent ( self , code : bool = False ) -> str : codes = CONTINENT_CODES if code else self . _data [ 'continent' ] return self . random . choice ( codes )
Get a random continent name or continent code .
34,032
def company_type ( self , abbr : bool = False ) -> str : key = 'abbr' if abbr else 'title' return self . random . choice ( self . _data [ 'company' ] [ 'type' ] [ key ] , )
Get a random type of business entity .
34,033
def currency_iso_code ( self , allow_random : bool = False ) -> str : if allow_random : return self . random . choice ( CURRENCY_ISO_CODES ) else : return self . _data [ 'currency-code' ]
Get code of the currency for current locale .
34,034
def price ( self , minimum : float = 10.00 , maximum : float = 1000.00 ) -> str : price = self . random . uniform ( minimum , maximum , precision = 2 ) return '{0} {1}' . format ( price , self . currency_symbol ( ) )
Generate a random price .
34,035
def price_in_btc ( self , minimum : float = 0 , maximum : float = 2 ) -> str : return '{} BTC' . format ( self . random . uniform ( minimum , maximum , precision = 7 , ) , )
Generate random price in BTC .
34,036
def fiscal_code ( self , gender : Optional [ Gender ] = None ) -> str : code = '' . join ( self . random . choices ( string . ascii_uppercase , k = 6 ) ) code += self . random . custom_code ( mask = '##' ) month_codes = self . _data [ 'fiscal_code' ] [ 'month_codes' ] code += self . random . choice ( month_codes ) birt...
Return a random fiscal code .
34,037
def get_random_item ( enum : Any , rnd : Optional [ Random ] = None ) -> Any : if rnd and isinstance ( rnd , Random ) : return rnd . choice ( list ( enum ) ) return random_module . choice ( list ( enum ) )
Get random item of enum object .
34,038
def randints ( self , amount : int = 3 , a : int = 1 , b : int = 100 ) -> List [ int ] : if amount <= 0 : raise ValueError ( 'Amount out of range.' ) return [ int ( self . random ( ) * ( b - a ) ) + a for _ in range ( amount ) ]
Generate list of random integers .
34,039
def urandom ( * args : Any , ** kwargs : Any ) -> bytes : return os . urandom ( * args , ** kwargs )
Return a bytes object containing random bytes .
34,040
def schoice ( self , seq : str , end : int = 10 ) -> str : return '' . join ( self . choice ( list ( seq ) ) for _ in range ( end ) )
Choice function which returns string created from sequence .
34,041
def custom_code ( self , mask : str = '@###' , char : str = '@' , digit : str = '#' ) -> str : char_code = ord ( char ) digit_code = ord ( digit ) code = bytearray ( len ( mask ) ) def random_int ( a : int , b : int ) -> int : b = b - a return int ( self . random ( ) * b ) + a _mask = mask . encode ( ) for i , p in enu...
Generate custom code using ascii uppercase and random integers .
34,042
def user ( self ) -> str : user = self . random . choice ( USERNAMES ) user = user . capitalize ( ) if 'win' in self . platform else user . lower ( ) return str ( self . _pathlib_home / user )
Generate a random user .
34,043
def users_folder ( self ) -> str : user = self . user ( ) folder = self . random . choice ( FOLDERS ) return str ( self . _pathlib_home / user / folder )
Generate a random path to user s folders .
34,044
def dev_dir ( self ) -> str : user = self . user ( ) folder = self . random . choice ( [ 'Development' , 'Dev' ] ) stack = self . random . choice ( PROGRAMMING_LANGS ) return str ( self . _pathlib_home / user / folder / stack )
Generate a random path to development directory .
34,045
def project_dir ( self ) -> str : dev_dir = self . dev_dir ( ) project = self . random . choice ( PROJECT_NAMES ) return str ( self . _pathlib_home / dev_dir / project )
Generate a random path to project directory .
34,046
def __sub ( self , string : str = '' ) -> str : replacer = self . random . choice ( [ '_' , '-' ] ) return re . sub ( r'\s+' , replacer , string . strip ( ) )
Replace spaces in string .
34,047
def extension ( self , file_type : Optional [ FileType ] = None ) -> str : key = self . _validate_enum ( item = file_type , enum = FileType ) extensions = EXTENSIONS [ key ] return self . random . choice ( extensions )
Get a random file extension from list .
34,048
def mime_type ( self , type_ : Optional [ MimeType ] = None ) -> str : key = self . _validate_enum ( item = type_ , enum = MimeType ) types = MIME_TYPES [ key ] return self . random . choice ( types )
Get a random mime type from list .
34,049
def file_name ( self , file_type : Optional [ FileType ] = None ) -> str : name = self . __text . word ( ) ext = self . extension ( file_type ) return '{name}{ext}' . format ( name = self . __sub ( name ) , ext = ext , )
Get a random file name with some extension .
34,050
def noun ( self , plural : bool = False ) -> str : key = 'plural' if plural else 'noun' return self . random . choice ( self . _data [ key ] )
Return a random noun in German .
34,051
def bitcoin_address ( self ) -> str : type_ = self . random . choice ( [ '1' , '3' ] ) letters = string . ascii_letters + string . digits return type_ + '' . join ( self . random . choice ( letters ) for _ in range ( 33 ) )
Generate a random bitcoin address .
34,052
def ethereum_address ( self ) -> str : bits = self . random . getrandbits ( 160 ) address = bits . to_bytes ( 20 , byteorder = 'big' ) return '0x' + address . hex ( )
Generate a random Ethereum address .
34,053
def credit_card_number ( self , card_type : Optional [ CardType ] = None ) -> str : length = 16 regex = re . compile ( r'(\d{4})(\d{4})(\d{4})(\d{4})' ) if card_type is None : card_type = get_random_item ( CardType , rnd = self . random ) if card_type == CardType . VISA : number = self . random . randint ( 4000 , 4999 ...
Generate a random credit card number .
34,054
def credit_card_expiration_date ( self , minimum : int = 16 , maximum : int = 25 ) -> str : month = self . random . randint ( 1 , 12 ) year = self . random . randint ( minimum , maximum ) return '{0:02d}/{1}' . format ( month , year )
Generate a random expiration date for credit card .
34,055
def credit_card_owner ( self , gender : Optional [ Gender ] = None ) -> dict : owner = { 'credit_card' : self . credit_card_number ( ) , 'expiration_date' : self . credit_card_expiration_date ( ) , 'owner' : self . __person . full_name ( gender = gender ) . upper ( ) , } return owner
Generate credit card owner .
34,056
def alphabet ( self , lower_case : bool = False ) -> list : case = 'uppercase' if not lower_case else 'lowercase' alpha = self . _data [ 'alphabet' ] . get ( case ) return alpha
Get an alphabet for current locale .
34,057
def level ( self ) -> str : levels = self . _data [ 'level' ] return self . random . choice ( levels )
Generate a random level of danger or something else .
34,058
def text ( self , quantity : int = 5 ) -> str : text = '' for _ in range ( quantity ) : text += ' ' + self . random . choice ( self . _data [ 'text' ] ) return text . strip ( )
Generate the text .
34,059
def words ( self , quantity : int = 5 ) -> List [ str ] : words = self . _data [ 'words' ] . get ( 'normal' ) words_list = [ self . random . choice ( words ) for _ in range ( quantity ) ] return words_list
Generate lis of the random words .
34,060
def swear_word ( self ) -> str : bad_words = self . _data [ 'words' ] . get ( 'bad' ) return self . random . choice ( bad_words )
Get a random swear word .
34,061
def quote ( self ) -> str : quotes = self . _data [ 'quotes' ] return self . random . choice ( quotes )
Get a random quote .
34,062
def color ( self ) -> str : colors = self . _data [ 'color' ] return self . random . choice ( colors )
Get a random name of color .
34,063
def _hex_to_rgb ( color : str ) -> Tuple [ int , ... ] : if color . startswith ( '#' ) : color = color . lstrip ( '#' ) return tuple ( int ( color [ i : i + 2 ] , 16 ) for i in ( 0 , 2 , 4 ) )
Convert hex color to RGB format .
34,064
def hex_color ( self , safe : bool = False ) -> str : if safe : return self . random . choice ( SAFE_COLORS ) return '#{:06x}' . format ( self . random . randint ( 0x000000 , 0xffffff ) )
Generate a random hex color .
34,065
def rgb_color ( self , safe : bool = False ) -> Tuple [ int , ... ] : color = self . hex_color ( safe ) return self . _hex_to_rgb ( color )
Generate a random rgb color tuple .
34,066
def answer ( self ) -> str : answers = self . _data [ 'answers' ] return self . random . choice ( answers )
Get a random answer in current language .
34,067
def issn ( self , mask : str = '####-####' ) -> str : return self . random . custom_code ( mask = mask )
Generate a random ISSN .
34,068
def isbn ( self , fmt : Optional [ ISBNFormat ] = None , locale : str = 'en' ) -> str : fmt_value = self . _validate_enum ( item = fmt , enum = ISBNFormat ) mask = ISBN_MASKS [ fmt_value ] . format ( ISBN_GROUPS [ locale ] ) return self . random . custom_code ( mask )
Generate ISBN for current locale .
34,069
def ean ( self , fmt : Optional [ EANFormat ] = None ) -> str : key = self . _validate_enum ( item = fmt , enum = EANFormat , ) mask = EAN_MASKS [ key ] return self . random . custom_code ( mask = mask )
Generate EAN .
34,070
def imei ( self ) -> str : num = self . random . choice ( IMEI_TACS ) num = num + str ( self . random . randint ( 100000 , 999999 ) ) return num + luhn_checksum ( num )
Generate a random IMEI .
34,071
def pin ( self , mask : str = '####' ) -> str : return self . random . custom_code ( mask = mask )
Generate a random PIN code .
34,072
def submit ( self , code : str , results : str = '' , prompt : dict = None ) -> dict : if self . nosub : return dict ( LOG = code , LST = '' ) prompt = prompt if prompt is not None else { } if results == '' : if self . results . upper ( ) == 'PANDAS' : results = 'HTML' else : results = self . results ll = self . _io . ...
This method is used to submit any SAS code . It returns the Log and Listing as a python dictionary .
34,073
def exist ( self , table : str , libref : str = "" ) -> bool : return self . _io . exist ( table , libref )
Does the SAS data set currently exist
34,074
def sasstat ( self ) -> 'SASstat' : if not self . _loaded_macros : self . _loadmacros ( ) self . _loaded_macros = True return SASstat ( self )
This methods creates a SASstat object which you can use to run various analytics . See the sasstat . py module .
34,075
def sasml ( self ) -> 'SASml' : if not self . _loaded_macros : self . _loadmacros ( ) self . _loaded_macros = True return SASml ( self )
This methods creates a SASML object which you can use to run various analytics . See the sasml . py module .
34,076
def sasqc ( self ) -> 'SASqc' : if not self . _loaded_macros : self . _loadmacros ( ) self . _loaded_macros = True return SASqc ( self )
This methods creates a SASqc object which you can use to run various analytics . See the sasqc . py module .
34,077
def sasutil ( self ) -> 'SASutil' : if not self . _loaded_macros : self . _loadmacros ( ) self . _loaded_macros = True return SASutil ( self )
This methods creates a SASutil object which you can use to run various analytics . See the sasutil . py module .
34,078
def sasviyaml ( self ) -> 'SASViyaML' : if not self . _loaded_macros : self . _loadmacros ( ) self . _loaded_macros = True return SASViyaML ( self )
This methods creates a SASViyaML object which you can use to run various analytics . See the SASViyaML . py module .
34,079
def _loadmacros ( self ) : macro_path = os . path . dirname ( os . path . realpath ( __file__ ) ) fd = os . open ( macro_path + '/' + 'libname_gen.sas' , os . O_RDONLY ) code = b'options nosource;\n' code += os . read ( fd , 32767 ) code += b'\noptions source;' self . _io . _asubmit ( code . decode ( ) , results = 'tex...
Load the SAS macros at the start of the session
34,080
def sasdata ( self , table : str , libref : str = '' , results : str = '' , dsopts : dict = None ) -> 'SASdata' : dsopts = dsopts if dsopts is not None else { } if results == '' : results = self . results sd = SASdata ( self , libref , table , results , dsopts ) if not self . exist ( sd . table , sd . libref ) : if not...
Method to define an existing SAS dataset so that it can be accessed via SASPy
34,081
def datasets ( self , libref : str = '' ) -> str : code = "proc datasets" if libref : code += " dd=" + libref code += "; quit;" if self . nosub : print ( code ) else : if self . results . lower ( ) == 'html' : ll = self . _io . submit ( code , "html" ) if not self . batch : self . DISPLAY ( self . HTML ( ll [ 'LST' ] )...
This method is used to query a libref . The results show information about the libref including members .
34,082
def upload ( self , localfile : str , remotefile : str , overwrite : bool = True , permission : str = '' , ** kwargs ) : if self . nosub : print ( "too complicated to show the code, read the source :), sorry." ) return None else : log = self . _io . upload ( localfile , remotefile , overwrite , permission , ** kwargs )...
This method uploads a local file to the SAS servers file system .
34,083
def df2sd ( self , df : 'pd.DataFrame' , table : str = '_df' , libref : str = '' , results : str = '' , keep_outer_quotes : bool = False ) -> 'SASdata' : return self . dataframe2sasdata ( df , table , libref , results , keep_outer_quotes )
This is an alias for dataframe2sasdata . Why type all that?
34,084
def dataframe2sasdata ( self , df : 'pd.DataFrame' , table : str = '_df' , libref : str = '' , results : str = '' , keep_outer_quotes : bool = False ) -> 'SASdata' : if libref != '' : if libref . upper ( ) not in self . assigned_librefs ( ) : print ( "The libref specified is not assigned in this SAS Session." ) return ...
This method imports a Pandas Data Frame to a SAS Data Set returning the SASdata object for the new Data Set .
34,085
def sd2df ( self , table : str , libref : str = '' , dsopts : dict = None , method : str = 'MEMORY' , ** kwargs ) -> 'pd.DataFrame' : dsopts = dsopts if dsopts is not None else { } return self . sasdata2dataframe ( table , libref , dsopts , method , ** kwargs )
This is an alias for sasdata2dataframe . Why type all that? SASdata object that refers to the Sas Data Set you want to export to a Pandas Data Frame
34,086
def sd2df_CSV ( self , table : str , libref : str = '' , dsopts : dict = None , tempfile : str = None , tempkeep : bool = False , ** kwargs ) -> 'pd.DataFrame' : dsopts = dsopts if dsopts is not None else { } return self . sasdata2dataframe ( table , libref , dsopts , method = 'CSV' , tempfile = tempfile , tempkeep = t...
This is an alias for sasdata2dataframe specifying method = CSV . Why type all that? SASdata object that refers to the Sas Data Set you want to export to a Pandas Data Frame
34,087
def sasdata2dataframe ( self , table : str , libref : str = '' , dsopts : dict = None , method : str = 'MEMORY' , ** kwargs ) -> 'pd.DataFrame' : dsopts = dsopts if dsopts is not None else { } if self . exist ( table , libref ) == 0 : print ( 'The SAS Data Set ' + libref + '.' + table + ' does not exist' ) return None ...
This method exports the SAS Data Set to a Pandas Data Frame returning the Data Frame object . SASdata object that refers to the Sas Data Set you want to export to a Pandas Data Frame
34,088
def disconnect ( self ) : if self . sascfg . mode != 'IOM' : res = "This method is only available with the IOM access method" else : res = self . _io . disconnect ( ) return res
This method disconnects an IOM session to allow for reconnecting when switching networks See the Advanced topics section of the doc for details
34,089
def exist ( self , table : str , libref : str = "" ) -> bool : code = "data _null_; e = exist('" if len ( libref ) : code += libref + "." code += table + "');\n" code += "v = exist('" if len ( libref ) : code += libref + "." code += table + "', 'VIEW');\n if e or v then e = 1;\n" code += "te='TABLE_EXISTS='; put te e;r...
table - the name of the SAS Data Set libref - the libref for the Data Set defaults to WORK or USER if assigned
34,090
def set_results ( self , results : str ) : if results . upper ( ) == "HTML" : self . HTML = 1 else : self . HTML = 0 self . results = results
This method set the results attribute for the SASdata object ; it stays in effect till changed results - set the default result type for this SASdata object . Pandas or HTML or TEXT .
34,091
def _returnPD ( self , code , tablename , ** kwargs ) : libref = kwargs . get ( 'libref' , 'work' ) ll = self . sas . _io . submit ( code ) check , errorMsg = self . _checkLogForError ( ll [ 'LOG' ] ) if not check : raise ValueError ( "Internal code execution failed: " + errorMsg ) if isinstance ( tablename , str ) : p...
private function to take a sas code normally to create a table generate pandas data frame and cleanup .
34,092
def where ( self , where : str ) -> 'SASdata' : sd = SASdata ( self . sas , self . libref , self . table , dsopts = dict ( self . dsopts ) ) sd . HTML = self . HTML sd . dsopts [ 'where' ] = where return sd
This method returns a clone of the SASdata object with the where attribute set . The original SASdata object is not affected .
34,093
def head ( self , obs = 5 ) : topts = dict ( self . dsopts ) topts [ 'obs' ] = obs code = "proc print data=" + self . libref + '.' + self . table + self . sas . _dsopts ( topts ) + ";run;" if self . sas . nosub : print ( code ) return if self . results . upper ( ) == 'PANDAS' : code = "data _head ; set %s.%s %s; run;" ...
display the first n rows of a table
34,094
def tail ( self , obs = 5 ) : code = "proc sql;select count(*) format best32. into :lastobs from " + self . libref + '.' + self . table + self . _dsopts ( ) + ";%put lastobs=&lastobs tom;quit;" nosub = self . sas . nosub self . sas . nosub = False le = self . _is_valid ( ) if not le : ll = self . sas . submit ( code , ...
display the last n rows of a table
34,095
def obs ( self ) : code = "proc sql;select count(*) format best32. into :lastobs from " + self . libref + '.' + self . table + self . _dsopts ( ) + ";%put lastobs=&lastobs tom;quit;" if self . sas . nosub : print ( code ) return le = self . _is_valid ( ) if not le : ll = self . sas . submit ( code , "text" ) lastobs = ...
return the number of observations for your SASdata object
34,096
def contents ( self ) : code = "proc contents data=" + self . libref + '.' + self . table + self . _dsopts ( ) + ";run;" if self . sas . nosub : print ( code ) return ll = self . _is_valid ( ) if self . results . upper ( ) == 'PANDAS' : code = "proc contents data=%s.%s %s ;" % ( self . libref , self . table , self . _d...
display metadata about the table . size number of rows columns and their data type ...
34,097
def columnInfo ( self ) : code = "proc contents data=" + self . libref + '.' + self . table + ' ' + self . _dsopts ( ) + ";ods select Variables;run;" if self . sas . nosub : print ( code ) return if self . results . upper ( ) == 'PANDAS' : code = "proc contents data=%s.%s %s ;ods output Variables=work._variables ;run;"...
display metadata about the table size number of rows columns and their data type
34,098
def sort ( self , by : str , out : object = '' , ** kwargs ) -> 'SASdata' : outstr = '' options = '' if out : if isinstance ( out , str ) : fn = out . partition ( '.' ) if fn [ 1 ] == '.' : libref = fn [ 0 ] table = fn [ 2 ] outstr = "out=%s.%s" % ( libref , table ) else : libref = '' table = fn [ 0 ] outstr = "out=" +...
Sort the SAS Data Set
34,099
def to_csv ( self , file : str , opts : dict = None ) -> str : opts = opts if opts is not None else { } ll = self . _is_valid ( ) if ll : if not self . sas . batch : print ( ll [ 'LOG' ] ) else : return ll else : return self . sas . write_csv ( file , self . table , self . libref , self . dsopts , opts )
This method will export a SAS Data Set to a file in CSV format .