AES AIG AIV
1/3/2008 1
2/6/2008 1
2/11/2008 1 1
!cat dd.csv
,AES,AIG,AIV
1/3/2008 16:00,,1,
2/6/2008 16:00,1,,
2/11/2008 16:00,1,,1
import pandas as pd
import numpy as np
s_input_file = 'dd1.csv'
df = pd.read_csv(s_input_file, sep=',',header=0) #orders.csv
def getcell(x):
if (x==1.0 and df.ix[x, df.ix[x]==1.0].values[0]==1.0):
print x, df.ix[x, df.ix[x]==1.0].index[0], df.ix[x][0]
df.applymap(getcell)
Got correct 4 counts of output but not referring to right index row and col "How to print the row index and column where cell == 1?"
1.0 AES 2/6/2008 16:00
1.0 AES 2/6/2008 16:00
1.0 AES 2/6/2008 16:00
1.0 AES 2/6/2008 16:00
How can I get the expected output like so:
1/3/2008, AIG
2/6/2008, AES
2/11/2008, AES
2/11/2008, AIG