Douglas Harper's Etymology Dictionary
"railroad maintenance worker," 1918, American English slang, of unknown origin; dancer perhaps from movements required in the work of tamping down ties or pumping a hand-cart, gandy perhaps from the name of a machinery belt company in Baltimore, Maryland.
Wiktionary
n. (context chiefly US idiomatic English) A railway laborer, especially a member of a crew which carry rails and affixes them to ties.
WordNet
n. a laborer in a railroad maintenance gang
Wikipedia
Gandy dancer is a slang term used for early railroad workers who laid and maintained railroad tracks in the years before the work was done by machines. The British equivalents of the term gandy dancer are " navvy" (from "navigator"), originally builders of canals or "inland navigations", for builders of railway lines, and " platelayer" for workers employed to inspect and maintain the track. In the U.S. Southwest and Mexico, Mexican and Mexican-American track workers were colloquially " traqueros".
In the U.S., early section crews were often made up of recent immigrants and ethnic minorities who vied for steady work despite poor wages and working conditions, and hard physical labor. The Chinese, Mexican Americans, and Native Americans in the West, the Irish in the Midwest, and East Europeans and Italians in the Northeast all worked as gandy dancers. Though all gandy dancers sang railroad songs, it may be that southern African American gandy dancers, with a long tradition of using song to coordinate work, were unique in their use of task-related work chants.
There are various theories about the derivation of the term, but most refer to the "dancing" movements of the workers using a specially manufactured "lining" bar, which came to be called a "gandy", as a lever to keep the tracks in alignment.
Usage examples of "gandy dancer".
I had worked that winter in the mountains of Mofo, Georgia, slugging it out as a gandy dancer, a man who pounds twelve-inch spikes with a fifteen-pound sledge.
Successful city political bosses held open court all through the twentieth century, leaving wide their office doors and listening to any gandy dancer or bindlestiff who came in.
I worked as a gandy dancer at a construction site where we used railroad ties to shore up the buildings.
He lingered two weeks and then won great obituaries as the most popular track foreman, boss gandy dancer, on the New York Central line.
He worked as water boy on a road construction crew, graduated to tool-room assistant, worked as a short-order cook, roughneck, gandy dancer, shrimp-boat hand, door-to-door encyclopedia salesman, swamper in a mine, wheat harvester, supplier of ink and needles to tattoo parlors, partner in a tire repair shop, and inmate in the Jim Hogg County jail for throwing a deputy sheriff out of a bar and grill, through a door that he hadn't observed was closed.