I am trying to delete certain information from a data frame, but the 'delete-command' (.drop) does not work like it should anyone got an idea?
My Code:
import pandas as pd
def join():
open_momox_xlsx = "momox_ergebnisse.xlsx"
open_rebuy_xlsx = "rebuy_ergebnisse.xlsx"
rebuy_xlsx = pd.read_excel(open_rebuy_xlsx)
momox_xlsx = pd.read_excel(open_momox_xlsx)
rebuy_data = rebuy_xlsx[['ReBuy']]
isbn_data = rebuy_xlsx[['ISBN']]
momox_data = momox_xlsx[['Momox']]
dataframe = pd.DataFrame =({'ISBN': isbn_data, 'Rebuy': rebuy_data, 'Momox': momox_data})
data = pd.concat(dataframe,axis=1, ignore_index=True)
c=0
#print(data[0])
while c < len(data):
if data[1][c] and data[2][c] == '///':
data.drop(index=c)
elif data[1][c] and data[2][c] < '1':
data.drop(index=c)
elif data[1][c] or data[2][c] < '1' and data[1][c] or data[2][c] == '///' :
data.drop(index=c)
c=c+1
print(data)
Output:
0 1 2
0 9783630876672 12,35 2.62
1 9783423282789 11,67 6.07
2 9783833879500 17,25 12.40
3 9783898798822 6,91 1.16
4 9783453281417 12,93 2.84
5 9783630876672 12,35 4.08
6 9783423282789 11,67 6.07
7 9783833879500 17,25 9.94
8 9783898798822 6,91 2.96
9 9783453281417 12,93 2.68
10 3927905909 /// ///
11 3872948210 /// 0.15
12 9783293003781 /// 0.15
13 9783423246842 /// ///
14 9783423247146 /// ///
15 9783423246934 /// ///
16 387294116x /// ///
17 9783935597456 0,16 0.15
18 9783423204545 /// ///
Wanted Output:
0 1 2
0 9783630876672 12,35 2.62
1 9783423282789 11,67 6.07
2 9783833879500 17,25 12.40
3 9783898798822 6,91 1.16
4 9783453281417 12,93 2.84
5 9783630876672 12,35 4.08
6 9783423282789 11,67 6.07
7 9783833879500 17,25 9.94
8 9783898798822 6,91 2.96
9 9783453281417 12,93 2.68
the if-statement seems to work properly, but the data.drop does not do what it should..