Skip to content

Instantly share code, notes, and snippets.

@beneon
Created January 15, 2020 02:08
Show Gist options
  • Select an option

  • Save beneon/c88fd2beb513ad211e33d78eea93d5f4 to your computer and use it in GitHub Desktop.

Select an option

Save beneon/c88fd2beb513ad211e33d78eea93d5f4 to your computer and use it in GitHub Desktop.

Revisions

  1. beneon created this gist Jan 15, 2020.
    38 changes: 38 additions & 0 deletions faker_gen.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,38 @@
    from faker import Faker
    import pandas as pd
    import os

    fk = Faker('zh_CN')


    class PtRecord:

    def __init__(self,fk):
    profile_selector = [
    'name',
    'sex',
    'job',
    'residence',
    'ssn',
    'birthdate',
    'blood_group',
    ]
    self.profile = fk.profile(fields=profile_selector)


    rst_list = []

    for i in range(10):
    rst_list.append(PtRecord(fk).profile)

    df = pd.DataFrame(rst_list)

    output_path = os.path.join('dataset','pt_simple.xlsx')
    xlwriter = pd.ExcelWriter(output_path, engine='xlsxwriter')

    df.to_excel(xlwriter,'病人数据',index=False)

    xlwriter.sheets['病人数据'].set_column('C:F',20)


    xlwriter.save()