Pycharm application trigger this issue where your PC suddenly gets rebooted causing the loss of unsaved data. This solution fixed my problem. Hope it helps you too. :) .. Happy coding.
Reference:
https://www.jetbrains.com/help/pycharm/local-history.html#local-history-retention