拆分废纸用熊猫列入列表
所以我在这里有一条基本的3行。在我打印航空公司[3]时给我提供所需的信息,但是如果我将其放入for for for for for'in in Airlines [3]中:'它只会打印出航空公司和目的地。我想把所有航空公司都列入自己的列表,我也希望所有目的地都在他们自己的列表中。
import pandas as pd
airlines = pd.read_html('https://en.wikipedia.org/wiki/Tan_Son_Nhat_International_Airport')
# Prints off table
print(airlines[3])
airlines_list = []
destination_list = []
So I have a basic 3 lines here. Gives me the info I want when I print airlines[3] but if I put it in a for loop like 'for i in airlines[3]:' it only prints out Airlines and Destinations. I want to take all the airlines put them into their own list and I want all the destinations in their own list too.
import pandas as pd
airlines = pd.read_html('https://en.wikipedia.org/wiki/Tan_Son_Nhat_International_Airport')
# Prints off table
print(airlines[3])
airlines_list = []
destination_list = []
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
航空公司[3]
是Pandas DataFrame。使用以下命令创建单独的列表:airlines[3]
is a pandas dataframe. Use below commands to create separate lists:如果您不想在其中任何一个列表中考虑重复项,则可以使用
set()
In case you want to not consider duplicates in either of those list , you can use
set()