What is the difference between 书呆子 and 迂夫子? Both 书呆子 and 迂夫子 mean a pedant, and at least I know 书呆子 is usually used in derogatory tone.

I have never seen the word 迂夫子 until just now, and it seems to mean the same thing as 书呆子.

So I wonder if there is any difference. Is it also a derogatory word, or anything others that differ?
书呆子 is most accurately translated as IYI (Intellectual yet idiot), a phrase coined by 
Nassim Taleb. While "nerd" in modern English often refers to someone who is rusty in social skills. 

迂夫子 is seldom used in modern Chinese. On those occasions they are used, it often refers to someone who adheres to strict moral code, sometimes in a way that embarrasses others. It is not a derogatory word, but sometimes used in a humorous tone.