我想用可选的开始和结束索引从Pandas数据框检索数据。例如,丑陋的方式是这样的
def get_data(self, start=None, end=None):
if start is None and end is not None:
return self.data[:end]
if start is not None and end is None:
return self.data[start:]
if start is not None and end is not None:
return self.data[start:end]
有什么优雅的方法吗?谢谢!在
相关问题 更多 >
编程相关推荐