Nowadays we say in the dumps, blue, low-spirited, instead of “in the doldrums”.
Nobody knows what a doldrum was originally, but possibly the word itself was derived from dull, “stupid,” or from the Middle English word dold, which had the same meaning.
At any rate doldrum referred originally to a dull or sluggish person, a dullard.
Literary use of the expression has been traced to less than a hundred and fifty years only, but I have a hunch that colloquial use goes back much further.
We speak of a ship being “in the doldrums” when it is becalmed. This nautical usage, however, is of later vintage.