Skip to content

Commit

Permalink
内存优化, 优化log.
Browse files Browse the repository at this point in the history
  • Loading branch information
enjoysport2022 committed Jul 26, 2021
1 parent 5cda17a commit ba93d45
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions autox/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def reduce_mem_usage(df):
to reduce memory usage.
"""
start_mem = df.memory_usage().sum() / 1024 ** 2
print('Memory usage of dataframe is {:.2f} MB'.format(start_mem))
log('Memory usage of dataframe is {:.2f} MB'.format(start_mem))

for col in df.columns:
col_type = df[col].dtype
Expand Down Expand Up @@ -58,7 +58,7 @@ def reduce_mem_usage(df):
df[col] = df[col].astype('category')

end_mem = df.memory_usage().sum() / 1024 ** 2
print('Memory usage after optimization is: {:.2f} MB'.format(end_mem))
print('Decreased by {:.1f}%'.format(100 * (start_mem - end_mem) / start_mem))
log('Memory usage after optimization is: {:.2f} MB'.format(end_mem))
log('Decreased by {:.1f}%'.format(100 * (start_mem - end_mem) / start_mem))

return df

0 comments on commit ba93d45

Please sign in to comment.