'New York Times columnist David Pogue takes aim at technology’s worst interface-design offenders, and provides encouraging examples of products that get it right. To funny things up, he bursts into song.'
iloc使用行列数字位置定位。dataframe.iloc[row_num,col_num]。
1 2 3
ted.iloc[3,1]
'In an emotionally charged talk, MacArthur-winning activist Majora Carter details her fight for environmental justice in the South Bronx -- and shows how minority neighborhoods suffer most from flawed urban policy.'
3. 合并数据
df1.append(df2)函数可以在dataframe后面增加另一个dataframe:
1 2 3 4 5 6 7 8 9
test = ted.loc[0:2,['comments','description']].append(ted.loc[5:6,['comments','description']]) test
comments description 04553 Sir Ken Robinson makes an entertaining and pro... 1265 With the same humor and humanity he exuded in ... 2124 New York Times columnist David Pogue takes aim... 5672 Tony Robbins discusses the "invisible forces" ... 6919 When two young Mormon missionaries knock on Ju...
df3= pd.concat([df1,df2])函数同样可以拼接2个DataFrame:
1 2 3 4 5 6 7 8 9
test = pd.concat([ted.loc[0:2,['comments','description']],ted.loc[5:6,['comments','description']]]) test
comments description 04553 Sir Ken Robinson makes an entertaining and pro... 1265 With the same humor and humanity he exuded in ... 2124 New York Times columnist David Pogue takes aim... 5672 Tony Robbins discusses the "invisible forces" ... 6919 When two young Mormon missionaries knock on Ju...
pd.merge(left,right,on='key')。merge函数和SQL的JOIN一样。
1 2 3 4 5 6 7 8 9 10
left = ted.loc[0:2,['description','comments']] right = ted.loc[0:3,['description','main_speaker']] pd.merge(left,right,on=['description'],how='left')
main_speaker description comments 0 Ken Robinson Sir Ken Robinson makes an entertaining and pro... 4553.0 1 Al Gore With the same humor and humanity he exuded in ... 265.0 2 David Pogue New York Times columnist David Pogue takes aim... 124.0 3 Majora Carter In an emotionally charged talk, MacArthur-winn... NaN
comments description duration event film_date 04553 Sir Ken Robinson makes an entertaining and pro... 1164 TED2006 1140825600 966404 Richard Dawkins urges all atheists to openly s... 1750 TED2002 1012608000