用csv

问题描述

我有一个看起来像的数据框

table = pd.DataFrame([['11','78','AAL331'],['22','88','UAL556'],['30','90','UA889']],columns=['lat','long','call'])

然后我得到的CSV看起来像

csv = pd.DataFrame([['AA','American Airlines','Cannot Be Determined'],['UA','United Airlines',['N11PP','Parks Dept','AS320']],columns=['call','operator','type'])

我希望我的table查看CSV调用列,并以一种table的方式在table['operator'] CSV中创建一个名为operator的新列。将查看我的table's call列的前两个字母,并使用适当的运算符填充新的table['operator']

Example: my table says AAL331 so it will read the AA and in the new column called operator write American Airlines. Same for UAL556. It will read the UA and in the new operator column write United Airlines

我一直在考虑在str.startswith调用列上使用CSV's,因为我不一定只希望阅读前两个字母,而是看到它以AA或UA开头因为我还有其他需要查看完整呼叫符号的数据(例如:N11PP)。

感谢您的帮助!

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)