微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

用csv

如何解决用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 举报,一经查实,本站将立刻删除。