简体   繁体   中英

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.

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()?

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. Any chance I could do THAT in one hit?

是的,您只需添加[]

US_forward_rates.iloc[:,[1]]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM