案例1
>>> import pandas as pd
>>> df=pd.DataFrame({'A':[1,2,3],'B':[1,2,3],'C':[1,2,3]})
>>> df
A B C
0 1 1 1
1 2 2 2
2 3 3 3
>>> df.loc[:,['A','B']]
A B
0 1 1
1 2 2
2 3 3
案例2
#coding:utf-8
import sys
import time
import re
import pandas as pd
EARTH_RADIUS = 6378.137
ord_data = pd.read_csv('ccc.csv',delimiter='\t')
ord_data.loc[0,'aaa']
################################################
from math import *
# input Lat_A γ<B6><C8>A
# input Lng_A <BE><AD><B6><C8>A
# input Lat_B γ<B6><C8>B
# input Lng_B <BE><AD><B6><C8>B
# output distance <BE><E0><C0><EB>(km)
def rad(d):
return d*pi/180.0
def calc(Lat_A, Lng_A, Lat_B, Lng_B):#给定两点经纬度,计算距离
radlat1 = rad(Lat_A)
radlat2 = rad(Lat_B)
a = abs(radlat1-radlat2)
b = abs(rad(Lng_A)-rad(Lng_B))
s = 2*asin(sqrt(pow(sin(a/2),2)+cos(radlat1)*cos(radlat2)*pow(sin(b/2),2)))
s = s*EARTH_RADIUS
s = round(s*10000)/10000
s = s*1000
return s;
#################################################
def timedis(start,end):#给定两个时间点,计算时间间隔
return time.mktime(time.strptime(end,'%Y-%m-%d %H:%M:%S')) - time.mktime(time.strptime(start,'%Y-%m-%d %H:%M:%S'))
#strptime() 函数根据指定的格式把一个时间字符串解析为时间元组
#返回用秒数来表示时间的浮点数
#################################################