I am trying to write a function which creates a dataframe first and groups it by a cloumn. Function takes line_count and distance as arguments. Here is the dataframe :