的使用pandas
包read_csv
,iloc
和values
方法例如:
import pandas as pd
from io import StringIO
data ="""
5000 0 0.3048 71.3 0.00266337 121.301
6300 0 0.3048 71.3 0.00266337 119.541
8000 0 0.3048 71.3 0.00266337 117.151
10000 0 0.3048 71.3 0.00266337 115.391
12500 0 0.3048 71.3 0.00266337 112.241
16000 0 0.3048 71.3 0.00266337 108.721
"""
df = pd.read_csv(StringIO(data), sep='\s+', header=None)
a = df.iloc[:, :5].values
b = df.iloc[:, 5].values
In [192]: a
Out[192]:
array([[ 5.00000000e+03, 0.00000000e+00, 3.04800000e-01,
7.13000000e+01, 2.66337000e-03],
[ 6.30000000e+03, 0.00000000e+00, 3.04800000e-01,
7.13000000e+01, 2.66337000e-03],
[ 8.00000000e+03, 0.00000000e+00, 3.04800000e-01,
7.13000000e+01, 2.66337000e-03],
[ 1.00000000e+04, 0.00000000e+00, 3.04800000e-01,
7.13000000e+01, 2.66337000e-03],
[ 1.25000000e+04, 0.00000000e+00, 3.04800000e-01,
7.13000000e+01, 2.66337000e-03],
[ 1.60000000e+04, 0.00000000e+00, 3.04800000e-01,
7.13000000e+01, 2.66337000e-03]])
In [193]: b
Out[193]: array([ 121.301, 119.541, 117.151, 115.391, 112.241, 108.721])
你可以使用'pandas''read_table'函數 –