def test_correct_number_of_rows_are_generated(): df = gen.generate( props={ 'region': gen.choice(data=['EMEA', 'LATAM', 'NAM', 'APAC'], weights=[0.1, 0.1, 0.3, 0.5]), 'sic_range': gen.sic_range(), 'sic': gen.sic_industry(sic_range_field='sic_range'), 'country': gen.country_codes(region_field='region'), 'client_name': gen.company_namer(field='sic', field_type='sic', countrycode_field='country') }, count=50, randomstate=np.random.RandomState(13031981)).to_dataframe() df['sic_range'] = df['sic_range'].apply(lambda x: x.name) df['sic'] = df['sic'].apply(lambda x: x.name) df['country'] = df['country'].apply(lambda x: x.alpha3_code) print(df)
def test_correct_number_of_rows_are_generated(): df = gen.generate( props={ 'region': gen.choice(data=['EMEA', 'LATAM', 'NAM', 'APAC'], weights=[0.1, 0.1, 0.3, 0.5]), "country": gen.country_codes(region_field='region'), "client_type": gen.choice(data=data.client_types()), "client_name": gen.company_namer(field='client_type', field_type='client_type', countrycode_field='country') }, count=50, randomstate=np.random.RandomState(13031981)).to_dataframe()
def run(seed=130319810): regions = ['NAM', 'EMEA', 'APAC', 'LATAM'] region_weights = [0.5, 0.3, 0.1, 0.1] df = gen.generate( props={ 'region': gen.choice( data=regions, weights=region_weights), 'country': gen.country_codes( region_field='region'), 'secondary-region': gen.choice( data=regions, weights=region_weights), 'secondary-country': gen.country_codes( region_field='secondary-region'), 'industry': gen.sic_range(), 'industry_code': gen.sic_industry('industry'), 'legal-name': gen.company_namer( field='industry_code', countrycode_field='country'), 'lei_code': gen.lei_code() }, count=50, randomstate=np.random.RandomState(seed) ).to_dataframe() # Cleanup the country and add the CCY df['prefered_ccy'] = df['country'].apply(lambda x: x.currency) df['country'] = df['country'].apply(lambda x: x.alpha3_code) df['secondary_ccy'] = df['secondary-country'].apply(lambda x: x.currency) df['secondary-country'] = df['secondary-country'].apply(lambda x: x.alpha3_code) print(df) return df
RS = np.random.RandomState(13031981) MODEL = MarkovModel(filename='./tests/client_data.json', randomstate=RS) RESULT = gen.generate_from_model(props={ "country": gen.country_codes(region_field='region'), "ev": gen.random_range(high=100000, low=10000000), "address": gen.address(country_field='country'), "contact_name": gen.person(country_field='country'), "client_name": gen.company_namer(field='client_type', field_type='client_type', countrycode_field='country') }, count=50, model=MODEL) def test_correct_number_of_rows_are_generated(): df = RESULT.to_dataframe() # remap obects into flat table df['country'] = df['country'].map(lambda x: x.alpha3_code) df['city'] = df['address'].map(lambda x: x.city) df['state'] = df['address'].map(lambda x: x.state) del df['address']