Need of $\tt abs()$ method when plotting a power spectral density for a given dataset

I am a newbie in signal processing and would like to know the significance of using the abs() function and squaring the values received as an output of fft() function of Python's scipy.fftpack library, used when trying to plot a power spectral density for a dataset. I have found that many of code examples to plot a power spectral density do use an abs() and then square the values obtained thereafter.

• Can anyone please provide me a reason for doing so?
• Can't we just directly plot the values obtained from fft() function in Python's scipy.fftpack library?

Here is the code I have written till now to plot a power spectral density by referring some of the code examples,

import scipy.io as sio
import numpy as np
Import matplotlib.pyplot as plt
import pandas as pd

data = df.values

from scipy.fftpack import fft,fftfreq
dft= fft(data)
PSD = np.abs(dft) ** 2

• This question might be helpful. – jojek Apr 8 '17 at 9:23
• Do you have gained information from the given answer? – Laurent Duval Apr 22 '17 at 15:13
• Yes. Quite a bit! – Jalaj Maheshwari May 3 '17 at 5:39

Complex sines, or cisoids, $e^{iw}$ are fundamental functions for the study of linear systems, even if the latter are real. And the FFT is a fast algorithm for a discretized version of the continuous Fourier transform.
So when you apply an FFT, it provides you with a bunch of coefficients $c_k$, which can be positive, negative, or complex. We are often interested in the energy carried by these coefficients, defined as their squared modulus, which can be computed "complex number times conjugate equals square of modulus", or $c_k\times \overline{c_k} =|c_k|^2$. This works with real numbers too. So instead of squaring up, you could as well multiply the FFT by its complex conjugate, pointwise.
Calling it "absolute value" is a bit of an abuse. This term is generally understood for real numbers only, and "modulus" would be a better term. However, abs is a very common term in this situation. Output after fft(data) are complex numbers having both real and imaginary parts, so if one wants to calculate power one should use both real and imaginary parts (because both of them contribute to energy/power of signal). And the way to do so is to take abs(dft) . Hence abs() is needed, before squaring up.