Porcine diarrhea is a global problem that leads to large economic losses of the porcine industry. There are numerous factors related to piglet diarrhea, and compelling evidence suggests that gut microbiota is vital to host health. However, the key bacterial differences between non-diarrheic and diarrheic piglets are not well understood. In the present study, a total of 85 commercial piglets at three pig farms in Sichuan Province and Chongqing Municipality, China were investigated. To accomplish this, anal swab samples were collected from piglets during the lactation (0–19 days old in this study), weaning (20–21 days old), and post-weaning periods (22–40 days), and fecal microbiota were assessed by 16S rRNA gene V4 region sequencing using the Illumina Miseq platform. We found age-related biomarker microbes in the fecal microbiota of diarrheic piglets. Specifically, the family Enterobacteriaceae was a biomarker of diarrheic piglets during lactation (cluster A, 7–12 days old), whereas the Bacteroidales family S24–7 group was found to be a biomarker of diarrheic pigs during weaning (cluster B, 20–21 days old). Co-correlation network analysis revealed that the genus Escherichia-Shigella was the core component of diarrheic microbiota, while the genus Prevotellacea UCG-003 was the key bacterium in non-diarrheic microbiota of piglets in Southwest China. Furthermore, changes in bacterial metabolic function between diarrheic piglets and non-diarrheic piglets were estimated by PICRUSt analysis, which revealed that the dominant functions of fecal microbes were membrane transport, carbohydrate metabolism, amino acid metabolism, and energy metabolism. Remarkably, genes related to transporters, DNA repair and recombination proteins, purine metabolism, ribosome, secretion systems, transcription factors, and pyrimidine metabolism were decreased in diarrheic piglets, but no significant biomarkers were found between groups using LEfSe analysis.