Skip to content

Commit

Permalink
Merge pull request #75 from komomoo/main
Browse files Browse the repository at this point in the history
fix: 数据清洗bug
  • Loading branch information
1nchaos authored Jul 4, 2024
2 parents b839949 + 5bcf70d commit 2c058d7
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions adata/stock/market/stock_market/stock_market_baidu.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,12 @@ def get_market(self, stock_code: str = '000001', start_date='1990-01-01', k_type
result_df['stock_code'] = stock_code
result_df['trade_date'] = result_df['trade_time']
result_df['trade_time'] = pd.to_datetime(result_df['trade_time']).dt.strftime('%Y-%m-%d %H:%M:%S')
# 5. 数据清洗,剔除成交量为0的异常数据
# 5. 数据清洗,剔除成交量且成交额为0的异常数据
result_df.replace('--', None, inplace=True)
result_df.replace('', None, inplace=True)
result_df['amount'] = result_df['amount'].astype(float)
result_df = result_df[result_df['amount'] > 0]
result_df['volume'] = result_df['volume'].astype(float)
result_df = result_df[(result_df['amount'] > 0) | (result_df['volume'] > 0)]
result_df['change'] = result_df['change'].str.replace('+', '').astype(float)
result_df['change_pct'] = result_df['change_pct'].str.replace('+', '').astype(float)
return result_df
Expand Down

0 comments on commit 2c058d7

Please sign in to comment.