簡體   English   中英

如何創建具有特定要求的新文本文件

[英]How to create a new textfile, with specific requirements

我已經被困在一個程序上很長時間了,真的可以使用一些幫助。 我有一個包含 20 人的文本文件,然后是每個人的 10 個結果。 我必須用它來處理這個程序

例子:

Erik Eriksson 11.47 12.7 10.98 12.04 12.0 12.43 10.47 11.82 10.91 10.37(第一行 20,文本文件 = Race_results.txt)

我需要編寫一個程序,將每個人的一些文本“如下面的示例”寫入一個新的文本文件。(也稱為 Sorted_race_results.txt)//output 的鏈接作為屏幕截圖: https://imgur.com/a/r3tRppm

Output:

阿爾賓·奧古斯特森

結果:10.55 11.33 12.44 13.55 14.77 14.99 15.66 16.88 17.99 18.12

最大:18.12

最小值:10.55

中位數:14.61

維拉·瓦爾弗里德森

結果:10.01 11.33 12.44 13.55 14.77 14.99 15.66 16.88 17.99 18.01

最大:18.01

最小:10.01

中位數:14.61

流程圖如何查找該程序?

你能分享一下你的輸入文件是什么樣子的嗎? I'm asking because if it's a csv or if there's a way you can convert the text file into a csv file, you can simply read this file in pandas, making it a pandas dataframe.

然后您需要做的就是應用 pandas 最小值、最大值和中值函數來為您返回值。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM