【问题标题】:How do I slice the list containing multiple variables in numpy?如何在 numpy 中对包含多个变量的列表进行切片?
【发布时间】:2020-09-06 15:51:32
【问题描述】:

我需要分割这个列表并且需要单独分开(Altitude=170,180 等)?

L=['"Altitude","height","Distance"','170,159,160','180,177,145']

【问题讨论】:

    标签: python python-3.x numpy numpy-ndarray numpy-slicing


    【解决方案1】:

    不太确定您需要什么,而且列表看起来很奇怪。转换成data.frame并拉出列?

    import pandas as pd
    
    L=['"Altitude","height","Distance"','170,159,160','180,177,145']
    
    df = pd.DataFrame([i.split(",") for i in L[1:]],
        columns=L[0].replace('"',"").split(","))
    
    df['Altitude']
    Out[34]: 
    0    170
    1    180
    

    【讨论】:

      猜你喜欢
      • 2012-05-21
      • 2015-10-01
      • 1970-01-01
      • 2020-09-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多