【发布时间】:2020-12-09 10:40:40
【问题描述】:
import pandas as pd
rows = [] #create rows
offset=50
for i in range(0,1000,offset):
rows.append([i, " "])
df = pd.DataFrame(rows, columns=["offset","Remark"]) # First data frame
First Data Frame
offset Remark
0 0
1 50
2 100
3 150
4 200
5 250
6 300
7 350
8 400
9 450
10 500
11 550
12 600
13 650
14 700
15 750
16 800
17 850
18 900
19 950
# second data frame imported from excel , which is as below
Start End
0 50 100
1 300 400
2 450 600
3 800 950
预期输出要求如下-在偏移列中“如果值介于或等于开始和结束之间,则备注列将标记为真”
offset Remark
0 0 False
1 50 True
2 100 True
3 150 False
4 200 False
5 250 False
6 300 True
7 350 True
8 400 True
9 450 True
10 500 True
11 550 True
12 600 True
13 650 False
14 700 False
15 750 False
16 800 True
17 850 True
18 900 True
19 950 True
【问题讨论】:
标签: python dataframe formatting conditional-statements