Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 23131

How to calculate the average value of adjection rows?

$
0
0

I have a text file like below:

apple_1 1 1 2apple_2 2 3 4apple_3 3 5 6book_1 1 4 5cook_1 2 4 3cook_2 4 6 9book_1 2 3 4..

The numbers in each row, except for the first column, are random.What I need is the average value of adjection rows.for the case above, the result should be like:

apple 2 3 4book 1 4 5cook 2 5 6book 2 3 4

The values in 'apple' were the average values of the first three rows.The values in 'book' were the vaerage values of the 4th row (no changes)...

If anyone knows how to conduct this through Python?Many thanks to any comments/suggestions.


Viewing all articles
Browse latest Browse all 23131

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>