text: # coding: utf-8
  import json
  import pandas as pd
  import numpy as np
  
  
  class DataEncoder(json.JSONEncoder):
      def default(self, obj):
          if isinstance(obj, pd.Timestamp):
              return obj.strftime("%Y-%m-%d")
          elif isinstance(obj, np.integer):
              return int(obj)
          elif isinstance(obj, np.floating):
              return float(obj)
          elif isinstance(obj, np.ndarray):
              return obj.tolist()
          else:
              return json.JSONEncoder.default(self, obj)
  
  
  def util_to_json_from_pandas(data):
      """
          将pandas数据转换成json格式
      """
  
      """需要对于datetime 和date 进行转换, 以免直接被变成了时间戳"""
      if 'datetime' in data.columns:
          data.datetime = data.datetime.apply(str)
      if 'date' in data.columns:
          data.date = data.date.apply(str)
      return json.loads(data.to_json(orient='records'))
  