如何从 Excel 的特定列和行定义参数?
我想从 Excel 文件中获取某些值的列表。
我尝试了这个:
import pandas as pd
df = pd.read_excel('Data.xlsx')
orders = df[['Order']].loc[[4,129]]
print(orders)
我获得了这个解决方案:
Order
4 18292839
129 83938292
但是我想要获得的解决方案是像这样的值列表中从4到129的顺序:
['18292839',....... ....(其他订单),'83938292']
如果有人可以帮助我,我将非常感激!
I want to obtain a list of certain values from an excel file.
I tried this:
import pandas as pd
df = pd.read_excel('Data.xlsx')
orders = df[['Order']].loc[[4,129]]
print(orders)
I obtained this solution:
Order
4 18292839
129 83938292
But the solution that I want to obtain is the orders from 4 to 129 in a list on values like this:
['18292839', .............. (other orders), '83938292']
If someone can help me I will be very grateful!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用
orders.values.tolist()
将pd.Series
转换为list
。有关将DataFrames
和Series
转换为list
的更多信息,您可以阅读 这里。You can use
orders.values.tolist()
to convertpd.Series
intolist
. More about convertingDataFrames
andSeries
into thelist
you can read here.