Код: Выделить всё
import pandas as pd
d = {'col1': [1, 2, 3], 'col2': [4, 5, 6]}
df = pd.DataFrame(d)
Код: Выделить всё
def calc_new_column(row):
''' creates new column based on values from other columns
args:
row: the rows of a pandas dataframe
return: value that goes into each row of the new coulmn of the dataframe
'''
# print(type(row))
if int(row['col1']) > 1:
if int(row['col2']) или в строке DOC )?
Подробнее здесь: [url]https://stackoverflow.com/questions/71286523/dataframe-apply-row-type[/url]
Мобильная версия