Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The response data of lb.secSusp is not clean #36

Open
wonderbeyond opened this issue Apr 14, 2018 · 0 comments
Open

The response data of lb.secSusp is not clean #36

wonderbeyond opened this issue Apr 14, 2018 · 0 comments

Comments

@wonderbeyond
Copy link

wonderbeyond commented Apr 14, 2018

susp_fields = [
    'symbol',
    'ann_date',
    'susp_date',
    'susp_time',
    'resu_date',
    'resu_time',
    'susp_reason'
]

df, msg = jaqs_api.query(
    view='lb.secSusp',
    symbol="",
    start_date="2010-01-01",
    end_date='',
    fields=','.join(susp_fields),
)

date_pat = re.compile(r'\d{8}')
time_pat = re.compile(r'^\d{1,2}:\d{1,2}(:\d{1,2})?$')

def is_valid_rec(rec):
    return bool(
        (not rec.ann_date or date_pat.match(rec.ann_date)) and
        (not rec.susp_date or date_pat.match(rec.susp_date)) and
        (not rec.susp_time or time_pat.match(rec.susp_time)) and
        (not rec.resu_date or date_pat.match(rec.resu_date)) and
        (not rec.resu_time or time_pat.match(rec.resu_time))
    )
    
nv = df.loc[ ~df.apply(is_valid_rec, axis=1) ]
nv

ann_date resu_date resu_time susp_date susp_reason susp_time symbol
17725 20160927 20160928 9:30:00 20160927 刊登重要公告 13:00: 00 600246.SH

Note the cell with 13:00: 00 in

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant