用CSV连接两列:Python

时间:2015-12-01 18:29:37

标签: python csv pandas

AuthorID    CityArrival CountryArrival  Departure   CountryDeparture    DateDeparture   DateArrival
1922    Paris   France  New York    UnitedState 2008-03-10  2001-02-02
1002    LosAngeles  UnitedState California  UnitedState 2008-03-10  2008-12-01
1901    Paris   France  Lagos   Nigeria 2001-03-05  2001-02-02
1922    Paris   France  NewYork UnitedState 2011-02-03  2008-12-01
1002    Paris   France  California  UnitedState 2003-03-04  2002-03-04
1099    Paris   France  Beijing China   2011-02-03  2009-02-04
1901    LosAngeles  UnitedState Paris   France  2001-03-05  2001-02-02

我想连接CityArrivalCountryArrival

3 个答案:

答案 0 :(得分:2)

import pandas as pd
df = pd.read_csv(path)
df['Arrival'] = df.CityArrival + ' ' + df.CountryArrival

答案 1 :(得分:0)

@Html.ActionLink(
   "Client[" + 
           HttpUtility.HtmlDecode(@ClientName().ToString()) +
           "]",
   "Index", "Home")

答案 2 :(得分:0)

试试这个: -

import pandas as pd
df = pd.read_csv(path)
df['Arrival'] = df['CityArrival'].map(str) + ' ' + df['CountryArrival'].map(str)