Created
January 15, 2020 02:08
-
-
Save beneon/c88fd2beb513ad211e33d78eea93d5f4 to your computer and use it in GitHub Desktop.
数据生成代码
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment