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 I have a dataframe called pdf I need to form a new data frame in the following format:
Year count 1985 2 1986 2 1987 3 How can do this efficiently in pandas?