1
我有一個數據框列表,我想創建一個新的數據框列表,它與前一個列表相同,但使用功能方法添加列。返回帶有附加列的大熊貓數據框
這是我的想法和我已經試過:
# I know this is possible. It will add a new column of True.
df['new_column'] = True
# However, it edits the dataframe, I want a functional approach that returns a new modified dataframe.
# Something like this.
df + ('new_column', True)
# Then I can use it in list comprehension. consider dfs is a list of dataframes.
[df + ('new_column', True) for df in dfs]
正是我在尋找的,謝謝。 – Israelg99