DECROMAX

Kumars Pandas task

Aug 24th, 2022
1,425
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.33 KB | None | 0 0
  1. import pandas as pd
  2.  
  3. source_path = "replace-example.csv" # change to your path
  4.  
  5. df = pd.read_csv(source_path, sep='\t')
  6. subset = df[["Gene", "Annotation", "No. isolates"]]
  7.  
  8. df = df.where(~df.notna(), 1) # fills all not null with 1
  9. df = df.fillna(0) # fills all null with 0
  10.  
  11. df[["Gene", "Annotation", "No. isolates"]] = subset
  12. df
Advertisement
Add Comment
Please, Sign In to add comment