I want to write a python script which reads the '.bash_history' file and prints the statistics. Also, I would like to print the command which was used the most. I was able to read the bash history through the terminal but I'm not able to do it through python programming. Can someone please help me with how to start with it?
Just some basic ideas, with important python functions for that:

read the file; open
go through all lines and sum up the number of occurences of a line; for, dict
in case you only want to check parts of a command (for example treat cd XY and cd .. the same), normalize the lines by removing the command arguments after the space; split
sort the sums and print out the command with the highest sum.
reading .bash_history file through python script