pandas选取数据可以通过 loc iloc  [] 来选取

使用loc选取某几列:

user_fans_df = sample_data.loc[:,['uid','fans_count']]

 

使用[] 来选取列

reader_login_freq_df = sample_data[['reader_uid','reader_login_freq','reader_age']]

[]选取,应该是返回了元数据的一份视图,本质上应该没有新生成一份数据。

loc应该是又返回了一份新的数据

相关文章:

  • 2022-12-23
  • 2021-08-06
  • 2022-12-23
  • 2022-12-23
  • 2021-12-05
  • 2022-12-23
猜你喜欢
  • 2021-06-06
  • 2022-12-23
  • 2022-02-23
  • 2021-08-20
  • 2021-09-25
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案