1 # 处理小数+符号
 2 def deal_data_symbol(dataframe, deal_list, symbol=None, floatformat=2):
 3     '''
 4     dataframe: 需要处理的dataframe
 5     deal_list: 需要处理的列,必须是可迭代
 6     symbol: 需要添加的符号,默认无
 7     floatformat:保留几位小数,默认为2位
 8     '''
 9     def data(x):
10         if str(x) != '':
11             y = '%.' + str(floatformat) + 'f'
12             if symbol != None:
13                 x = y % x + symbol
14             else:
15                 x = y % x
16         return x
17 
18     for i in deal_list:
19         dataframe[i] = dataframe[i].map(data)
20     return dataframe

相关文章:

  • 2022-12-23
  • 2021-08-01
  • 2021-11-07
  • 2022-12-23
  • 2022-12-23
  • 2021-11-29
  • 2022-12-23
  • 2021-12-02
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-06-11
  • 2022-01-01
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案