首页 > 解决方案 > 从python中混合整数和字符串的未索引列中查找最大值

问题描述

I have a data without column headers and I want to find the max and min latitude and longitude which is index[2] and index[4] followed by index[3]=N and index[5]=E.

Example of the data is as follows:

1,5,6,9n,8,4,9,0

3,66,t,87,5,8

2,s,1.23,N,1.39,E

1,2,1.45,N,1.26,E,2N,9

7,-3,5,L,67,34,K,78,6,4

我尝试了以下方法:

with open ("E:\\abc\xyz.txt", "r") as file1:
        Lines = file1.readlines()
        data = Lines
        for line in Lines:
                spline = line.split(",")
                l1= []
                l1.append(spline[2])
                print(l1)

得到一个组合列表,这样我就可以得到一个 max()。但是无法弄清楚。`结果图像如下:

['6']

['t']

['1.23']

['1.45']

['5']

任何帮助表示赞赏。

标签: python-3.xlist

解决方案


谢谢你们。我最终找到了这个问题的解决方案。我用了

pd.read_csv

以及 index[2] & [4] 的 max() 再次感谢


推荐阅读