pandas常用方法示例 2
from pandas import DataFrame import numpy as np import pandas as pd t={ "age": [18, 30, np.nan, 40, np.nan, 30], "city": ["BeiJing", "ShangHai", "GuangZhou", "ShenZhen", ‘BeiJing‘, "ShangHai"], "sex": [None, "male", "female", "male", np.nan, "unknown"], "birth": ["2000-02-10", "1988-10-17", None, "1978-08-08", np.nan, "1988-10-17"], "score":[11,7,33,44,22,33], "naem":[‘sdf‘,‘aa‘,‘bb‘,‘tt‘,‘ere‘,‘tt‘], "name":[‘sdf 11‘,‘aa 22‘,‘bb 33‘,‘tt 44‘,‘ere 55‘,‘tt 66‘] } df =DataFrame(t,index=[‘num1‘,‘num2‘,‘num3‘,‘num4‘,‘num5‘,‘num6‘]) print(df.loc[df.index[[2,3]],[‘age‘,‘name‘]])
相关推荐
三石 2020-10-30
roamer 2020-10-29
三石 2020-10-29
wangquannuaa 2020-10-15
wangquannuaa 2020-09-29
jzlixiao 2020-09-15
wangquannuaa 2020-08-30
三石 2020-08-23
逍遥友 2020-08-21
jzlixiao 2020-08-18
wangquannuaa 2020-08-17
QianYanDai 2020-08-16
cjsyrwt 2020-08-14
jzlixiao 2020-07-29
xirongxudlut 2020-07-20
mmmjyjy 2020-07-16
QianYanDai 2020-07-05
QianYanDai 2020-07-05
june0 2020-07-04