if filtered_objects_profits[index] # допишите новое условие
если значение filtered_objects_profits[index] больше 500000
import pandas as pd
d1 = {"A": ["TRUE", "FALSE", "FALSE", "TRUE"],
"B": ["0.78", "0.35", "0.14", "0.99"]}
d2 = {"C": [1, 0, 1, 1],
"D": [1.52, 1.22, 2.64, 3.63]}
df1 = pd.DataFrame(d1)
df2 = pd.DataFrame(d2)
print("********\n", df1)
print("********\n", df2)
df3 = pd.concat([df1, df2], axis=1)
print("********\n", df3)
# CSV
df3.to_csv('/tmp/out.csv', index=True)
# напечатает:
********
A B
0 TRUE 0.78
1 FALSE 0.35
2 FALSE 0.14
3 TRUE 0.99
********
C D
0 1 1.52
1 0 1.22
2 1 2.64
3 1 3.63
********
A B C D
0 TRUE 0.78 1 1.52
1 FALSE 0.35 0 1.22
2 FALSE 0.14 1 2.64
3 TRUE 0.99 1 3.63
# файл:
$ cat out.csv
,A,B,C,D
0,TRUE,0.78,1,1.52
1,FALSE,0.35,0,1.22
2,FALSE,0.14,1,2.64
3,TRUE,0.99,1,3.63
rows_N = int(input("Введите количество строк N (N>=1): "))
if rows_N >= 1:
column_K = int(input("Введите количество столбцов K (K>=3): "))
if column_K >= 3:
mas = [[0 for j in range(column_K)] for i in range(rows_N)]
k = 0
n = 0
for k in range(1, column_K + 1):
for n in range(1, rows_N + 1):
if k == 1:
x = 1
else:
x = int(1 / 2 * k * (n**2 - n) - n**2 + 2 * n)
mas[n - 1][k - 1] = x
for row in mas:
print(", ".join([f"{x:>4}" for x in row]))
Введите количество строк N (N>=1): 15
Введите количество столбцов K (K>=3): 10
1, 1, 1, 1, 1, 1, 1, 1, 1, 1
1, 2, 3, 4, 5, 6, 7, 8, 9, 10
1, 3, 6, 9, 12, 15, 18, 21, 24, 27
1, 4, 10, 16, 22, 28, 34, 40, 46, 52
1, 5, 15, 25, 35, 45, 55, 65, 75, 85
1, 6, 21, 36, 51, 66, 81, 96, 111, 126
1, 7, 28, 49, 70, 91, 112, 133, 154, 175
1, 8, 36, 64, 92, 120, 148, 176, 204, 232
1, 9, 45, 81, 117, 153, 189, 225, 261, 297
1, 10, 55, 100, 145, 190, 235, 280, 325, 370
1, 11, 66, 121, 176, 231, 286, 341, 396, 451
1, 12, 78, 144, 210, 276, 342, 408, 474, 540
1, 13, 91, 169, 247, 325, 403, 481, 559, 637
1, 14, 105, 196, 287, 378, 469, 560, 651, 742
1, 15, 120, 225, 330, 435, 540, 645, 750, 855
from pathlib import Path
from skimage.metrics import structural_similarity
import cv2
import sys
path = Path(sys.argv[1])
ref = path / "reference standard.jpg"
imref = cv2.imread(ref.as_posix())
grayref = cv2.cvtColor(imref, cv2.COLOR_BGR2GRAY)
info = []
for m in path.iterdir():
if "reference standard.jpg" == m.name:
continue
im = cv2.imread(m.as_posix())
try:
gray = cv2.cvtColor(im, cv2.COLOR_BGR2GRAY)
score, difference = structural_similarity(grayref, gray, full=True)
info.append((score, m.as_posix()))
except Exception:
print(f"{m} is bad")
for score, path in sorted(info):
print(score, path)
import pandas as pd
df = pd.DataFrame({"friends": ["Сергей", "Соня", "Дима", "Алина", "Егор"]})
print('У тебя '+ str(df.nunique().friends) + ' друзей')
import math
for num in [2, 10, 20]:
summa = 0
print(f"{range(1, int(math.sqrt(num)) + 1)}")
for i in range(1, int(math.sqrt(num)) + 1):
if num % i == 0:
summa += i
print(f"summa += {i}")
if i == 1 or num % i == i:
if i == 1:
print(f"continue from i == 1")
elif num % i == i:
print(f"continue from {num} % {i} == {i}")
continue
else:
print(f"{num} % {i} != {i} ({num % i})")
summa += num // i
print(f"{num} // {i} == {num // i}")
print(f"{num=} {summa=}")
print()
def main():
data = {"ABC": "2", "DEF": "3", "GHI": "4",
"JKL": "5", "MNO": "6", "PQRS": "7",
"TUV": "8", "WXYZ": "9"}
number = input("Введите телефонный номер: ")
for x in number:
if x.isalpha():
for trio in data:
if x in trio:
number = number.replace(x, data[trio])
break
print(number)
main()