从列表中遍历熊猫数据框

问题描述 投票:0回答:1

我有一个时间戳列表:

[Timestamp('2018-01-08 00:00:00'),
 Timestamp('2018-01-22 00:00:00'),
 Timestamp('2019-11-18 00:00:00'),
 Timestamp('2019-12-12 00:00:00'),
 Timestamp('2020-01-06 00:00:00'),
 Timestamp('2020-02-10 00:00:00'),
 Timestamp('2020-04-02 00:00:00')]

我如何只用对应的DateLow列迭代熊猫数据帧的时间戳:

                   High          Low  ...    Adj Close    bcc
Date                                  ...                    
2018-01-02  2695.889893  2682.360107  ...  2695.810059  False
2018-01-03  2714.370117  2697.770020  ...  2713.060059  False
2018-01-04  2729.290039  2719.070068  ...  2723.989990  False
2018-01-05  2743.449951  2727.919922  ...  2743.149902  False
2018-01-08  2748.510010  2737.600098  ...  2747.709961   True
                ...          ...  ...          ...    ...
2020-04-09  2818.570068  2762.360107  ...  2789.820068  False
2020-04-13  2782.459961  2721.169922  ...  2761.629883  False
2020-04-14  2851.850098  2805.100098  ...  2846.060059  False
2020-04-15  2801.879883  2761.540039  ...  2783.360107  False
2020-04-16  2806.510010  2764.320068  ...  2799.550049  False

[576 rows x 7 columns]

类似:

for i in timestmp:
    for Date, row in data.Low.iterrows():
        print(Low)

上面的代码是错误的,并给出一个错误:AttributeError: 'Series' object has no attribute 'iterrows'我该怎么做才能做到这一点?

python pandas list time-series series
1个回答
0
投票

首先按列表和列LowSeries选择行:

© www.soinside.com 2019 - 2024. All rights reserved.