This paper develops a compositional learning algorithm for coupled dynamical systems, focusing specifically on electrical networks. While deep learning has proven effective in modeling complex relationships from data, the compositional coupling between system components poses a challenge for many existing data-driven approaches to modeling dynamical systems, which typically impose algebraic constraints on state variables. To develop a deep learning model for constrained dynamical systems, this paper introduces neural port-Hamiltonian differential-algebraic equations (N-PHDAEs), which use neural networks to parameterize unknown terms in both the differential and algebraic components of port-Hamiltonian DAEs. To train these models, we perform index reduction using automatic differentiation and propose an algorithm that automatically transforms neural DAEs into equivalent neural ordinary differential equations (N-ODEs) for which conventional model inference and backpropagation methods exist. Experiments simulating the dynamics of nonlinear circuits demonstrate the benefits of the proposed approach. The proposed N-PHDAE model achieves a tenfold improvement in prediction accuracy and constraint satisfaction over a long forecast horizon compared to the baseline N-ODE. Furthermore, we validate the approach's composability through experiments on a simulated DC microgrid. Individual N-PHDAE models are trained for individual grid components and then combined to accurately predict the behavior of a large-scale network.