df1 = pd.DataFrame({'end': [2007, 2013, 2014, 2013, 2014], 'id.thomas'\
: ['136', '136', '136', '172', '172'], 'years_exp': ['14', '20', '21', \
'14', '15']}, index=[2,3,4,5,6])
end id.thomas years_exp
2 2007 136 14
3 2013 136 20
4 2014 136 21
5 2013 172 14
6 2014 172 15
其中end
代表的年。我想擴大end
和years_exp
列佔賬戶失蹤多年:
end id.thomas years_exp
2 2007 136 14
3 2008 136 15
4 2009 136 16
5 2010 136 17
6 2011 136 18
7 2012 136 19
8 2013 136 20
9 2014 136 21
10 2013 172 14
11 2014 172 15
我一直在這約20個小時,試圖「工程師」的修正。有誰知道一個簡單的Python /熊貓工具/方法來完成這項任務嗎?
你關心的索引順序? 'id.thomas'和'years_exp'列是否被計算出來,還是可以讓它們變空? –
@Nathan Clement:謝謝你的迴應。我不關心索引順序。保持'id.thomas'非常重要。 '年代表達式'是我從這次行動中脫身的主要原因。它稍後將被合併到另一個數據庫。 '年表達式'已經從另一個[dataframe](https://github.com/108michael/ms_thesis/blob/master/yearsofserv) –
計算出來了。所以基本上你想要的是有一個新的範圍的「結束」行開始第一年和去年結束,但不跳過任何年份? –