For a bear with the gut of a carnivore, modern pandas have carved out a bizarre niche in the plant-eating world.

Key points: Giant pandas, which are classed as carnivores, exist almost exclusively on a diet of bamboo

Giant pandas, which are classed as carnivores, exist almost exclusively on a diet of bamboo Analysis of bones and teeth of extinct panda species provides evidence of dietary specialisation and shrinking habitats over the past 2 million years

Analysis of bones and teeth of extinct panda species provides evidence of dietary specialisation and shrinking habitats over the past 2 million years New research suggests modern pandas may have switched to an almost bamboo-only diet about 5,000 years ago

Today's giant pandas (Ailuropoda melanoleuca) live in the cool mountains of south-western China, where they spend their days almost exclusively eating bamboo.

But their ancient ancestors, living at least 5,000 years ago, had a much more varied diet of bamboo and other plants, according to a new study published today in the journal Current Biology.

"We don't know what the exact plants were, but their diet was similar with herbivores such as deer during that time," said the study's lead author, Fuwen Wei of the Chinese Academy of Science.

Modern pandas have distinctive teeth, skull and muscles and a specialised thumb to pin down and crush between 12-38 kilograms of bamboo each day.

But they have a short gut and a microbiome not well suited to digesting plant material, suggesting they originally evolved from an extinct carnivorous ancestor.

Previous fossil evidence suggests the panda family started to develop a taste for plants about 2 million years ago.

At that time, the ancestors of today's pandas lived across a much wider range of China and South-East Asia; from Beijing in the north, to Myanmar, northern Vietnam, Laos and Thailand in the south.

Today, pandas are confined to a small number of mountains in south-western China. ( Goodfreephotos: Chester Ho )

To understand the diet of extinct species, Dr Wei and colleagues analysed chemical signatures in the bones of 12 ancient pandas that lived up until around 5,000 years ago.

They compared this with carbon and nitrogen ratios from samples of collagen and teeth from modern pandas and other mammals from the same area collected between 1970 and the 2000s.

The analysis showed all panda species lived on a pure C3 plant diet — the most common group of plants typical of forests — for the past 2 million years.

But the nitrogen isotopes in the bones and teeth of the modern and ancient groups were distinctly different.

"Modern panda that feed on just bamboo had very low nitrogen isotopes, but the ancient pandas had very high levels equal to herbivores," Dr Wei said.

This suggested that ancient pandas had much more complicated diets than today.

It also indicated they may have lived in more diverse habitats, such as sub-tropical zones and forest fringes, backing up archaeological records from southern to northern China where fossils have been found.

Shift to 99 per cent bamboo

It is unclear when or why giant pandas became almost exclusively bamboo eaters — albeit with the odd bit of grass or meat on the menu in the wild.

The first description of their bamboo diet is only a few hundred years old, but the researchers suspect the shift happened about 5,000 years ago.

To find out, they hope to study more panda fossils.

"We need to get more samples from different years after 5,000 years ago, but it is hard to do this," Dr Wei said.

Dr Wei said it was possible the switch came about as an adaptation to a shrinking range, "but we do not know the exact reasons".

"Maybe it is a complicated [mix of] climate change, human encroachment and species competition for resources," Dr Wei said.

Pandas such as Fu Ni at Adelaide Zoo also like sweet treats such as apples and pears. ( AAP: Zoos South Australia )

Bamboo provides pandas with a perpetual source of food that very few other animals can exploit, said David Raubenheimer of the University of Sydney, who was not involved in this study but has previously researched the animal's dietary habits.

Not all bamboo is equal, however.

"It's not a question of them just eating anything before them," Professor Raubenheimer said.

"We've now got evidence they carefully select among the different options available to them from the sea [of bamboo] in which they live."

This evidence indicates that pandas must migrate to select bamboo that meets their seasonal nutritional needs.

"They migrate in summer to get high protein intakes, then in winter they migrate down to habitats that provide low protein, but high calcium required for reproduction," Professor Raubenheimer said.

"Probably ancestrally that wasn't necessary because in any habitat they had a broader diet because they had proteins in some foods and calcium from others."

Today's giant pandas, which are listed as vulnerable, live on various species of bamboo scattered across 20 isolated patches in six mountain ranges in Sichuan, Shaanxi and Gansu provinces.

In a world of shrinking habitats, being a fussy eater is both a blessing and a curse.