I have a dataframe that looks like this:
df = pd.read.csv("variants.csv")
print(df)
Sample Position Reference Alt
Sample1 123 C T
Sample2 123 C T
Sample3 1234 C G
and a list of 'Positions' of interest:
pos = [123, 1334, 1443, 133]
I want to map the column of 'Position' to my list and create a new column in the dataframe where if 'Position' exists == 1 else I assign a value of 0. Example:
Sample Position Reference Alt Value
Sample1 123 C T 1
Sample2 123 C T 1
Sample3 1234 C G 0
How can I do this in Pandas or another way? Apologies as I'm a beginner to python.