Python Extracting dynamic amount of columns -
i'm wondering how best approach problem. have 2 dataframes:
df1 3 4 5 6 0 nan nan sea nan 1 light medium light medium 2 26 41.5 15 14 3 32 40 18 29 4 41 29 19 42 df2 3 4 5 6 7 8 0 nan nan nan sea nan nan 1 light medium heavy light medium heavy 2 26 41.5 21 15 14 29 3 32 40 19 18 29 31 4 41 29 18 19 42 35 and trying isolate 'sea' column range such:
df1 5 6 0 sea nan 1 light medium 2 15 14 3 18 29 4 19 42 df2 6 7 8 0 sea nan nan 1 light medium heavy 2 15 14 29 3 18 29 31 4 19 42 35 my initial thought somehow drop first column instances of 'light' , 'medium' or 'light' 'medium' 'heavy'. i'm not quite sure how achieve that. if has better idea/solution please feel free let me know. apologize lack of attempt don't know how approach problem
ok here answer dynamically. may not fastest
for col in df1: if df1.loc[0,col] == 'sea': break else: del df1[col] then same thing second dataframe
Comments
Post a Comment