If you want to keep the dimensions when counting along an axis in a NumPy array, you can use the np.sum() function with the axis and keepdims parameters.