MJP*_*MJP 2 python python-2.7 pandas
dictionary = {'Year': [1985, 1985, 1986, 1986, 1987, 1987, 1987]}
pdf = pd.DataFrame(dictionary)
Year
0 1985
1 1985
2 1986
3 1986
4 1987
5 1987
6 1987
Run Code Online (Sandbox Code Playgroud)
我有一个名为pdf
我需要形成new data frame
以下格式的数据框:
Year count
1985 2
1986 2
1987 3
Run Code Online (Sandbox Code Playgroud)
如何在 pandas 中有效地做到这一点?