I am trying to create an empty data frame and filling the empty data frame with columns existing in another file. It works when i use this simple code.
InputData['Quote'] = store['QUOTE_ID']
but when i add some conditions before the code then it does not accept the conditions and gives same values as in store(original)file. below is my code i am trying to use .
original data set
InputData = pd.read_csv('datalink')
creating empty data frame
OutputData=pd.DataFrame()
code with conditions
for i in xrange(len(InputData.index)):
if (i % 5000) == 0:
print i,
if ((InputData.ix[i,'WIN']=='Y') and ((InputData.ix[i,'COM_C']=='H') or (InputData.ix[i,'COM_C']=='S')) and(InputData.ix[i,'COM_L']!=0)):
OutputData['Quote']=InputData['QUOTE_ID']
OutputData['ComList']=InputData['COM_LISTPR']
OutputData['WIN']=1
OutputData['COM_C']=InputData['COM_C']
OutputData.to_csv(link,index=False)
original data set
QUOTE_ID WIN COM_C COM_L
1400453-IT N H 1.46E+05
1400453-IT N H 7.12E+04
1400453-IT N H 2.74E+04
1403796-IT Y S 3.11E+04
1400453-IT N M 3.12E+02
1403796-IT Y H 3.97E+04
1403796-IT Y H 3.97E+04
1403796-IT Y M 1.99E+02
1403796-IT Y M 1.99E+02
1403796-IT Y H 7.40E+04
1403796-IT Y H 7.40E+04
1403796-IT Y M 3.19E+02
1403796-IT Y M 3.19E+02
1403796-IT Y H 9.56E+04
expected data set
require only Y from InputData and replace to 1 if Y
Quote WIN COM_C COM_LISTPR
1403796-IT 1 S 3.11E+04
1403796-IT 1 H 3.97E+04
1403796-IT 1 H 3.97E+04
1403796-IT 1 H 7.40E+04
1403796-IT 1 H 7.40E+04
1403796-IT 1 H 9.56E+04
many thanks in advance