I want to run a function on rows of a pandas dataframe in list comprehension. Dataframe can have varying number of columns. How to make use these columns of dataframe?
import pandas as pd
df = {'chrom': ['chr1', 'chr1','chr1'], 'start': [10000, 10100, 12000], 'end':[10150,10120,12250], 'S1':[1, 1, 1],'S2':[2, 2, 2],'S3':[3, 3, 3] }
df = pd.DataFrame(data=df)
print(df)
def func(row):
print(row)
[func(row) for row in zip(df['chrom'],df['start'],df['S1'],df['S2'],df['S3'])]
How to do this in a memory efficient way? So that we do not get any memory error for big dataframes.