[英]Create a DataFrame from another DataFrame by column
I would like to create a data frame from another data frame - but I want to do it by specifying the coordinates. 我想从另一个数据框创建一个数据框-但我想通过指定坐标来做到这一点。 In this case I want the new DataFrame to contain only the first column.
在这种情况下,我希望新的DataFrame仅包含第一列。
The following is correct in that it works: 以下是正确的,因为它可以工作:
US_effective_rate = US_forward_rates.iloc[:,1].copy()
US_effective_rate = US_effective_rate.to_frame()
I was wondering if there's a better implementation, possibly using .filter()? 我想知道是否有更好的实现,可能使用.filter()?
there are similar questions but they reference column names, not coordinates. 有类似的问题,但它们引用的是列名,而不是坐标。
thank you very much. 非常感谢你。
PS: I actually just want the dimensions and index from the first frame, going to overwrite the actual data. PS:实际上,我只想要第一帧的尺寸和索引,以覆盖实际数据。 Any chance I could do THAT in one hit?
我有机会一击就做到吗?
是的,您只需添加[]
US_forward_rates.iloc[:,[1]]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.