i ahve used following code to save value-counts in separate files.it work for two values.but my dataframe conatins maximum 4 keys ,it varies like(1978,1821), (1900,1978,1821,200)(1821,2000,1900). how can i modify the code to make it generic
start=0,end=100 for i in range(start,len(df1),100): df2=df1.iloc[start:end,] value=df2[2].value_counts().keys().tolist() counts=df2[2].value_counts().tolist() k=0 for items in value : if items==1978 : filewriterstock.writerow([start, counts[k]]) if items==1821 : filewriterservive.writerow([start, counts[k]]) k=k+1 start=end end=end+100