在使用Python处理MySQL5.6版本的数据时,由于不能进行子查询,在纵表转横表时不是很方便,研究来一下在Python中来实现。类似于这样的转化
Python里类似数据库的纵表转横表操作
ser = df[[‘ctp_account_id’,‘exchange’,‘pos_hold_margin’,‘avail_ratio’,‘trade_date’]]
ser = ser.set_index([‘ctp_account_id’,‘trade_date’,‘exchange’])
ser = ser.unstack(‘exchange’)
ser =ser.reset_index()
print(ser)
Python里类似数据库的纵表转横表操作
Python里类似数据库的纵表转横表操作

相关文章:

  • 2022-02-15
  • 2021-12-03
  • 2021-07-04
  • 2022-12-23
  • 2022-12-23
  • 2021-09-21
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-19
  • 2021-12-12
  • 2022-12-23
  • 2022-01-08
相关资源
相似解决方案