#To calculate average and unique value from a text file using pandas python.
I am having a text file which is having two columns separated by "," and it is not having any column header. Column[0] has the taxi number and column[1] is having the number of km it had driven.
I want to calculate each taxi's how much km driven, how many times, and the average km driven by a taxi.
For example 00005 has driven 49 km, 3 times and the average is 16.33
00000,43
00001,43
00002,54
00000,43
00005,20
00004,15
00001,11
00005,8
00005,21
00004,5
I tried using
df.groupby(df.columns[0])[df.columns[-1]].sum()
- this is giving only sum
and df.groupby(df.columns[0])[df.columns[-1]].mean
- it is giving mean value but not average
Can someone please guide