Issue
I have an pandas-Dataframe, that I created from a csv (technically I have several dfs created from several csvs, but that doesn't matter here ...)
I want to output len(df.column))
if another column does not contain a string.
interim_2_df = pd.read_csv("interim_26/ch_02.csv", sep=";", header=[0])
print(interim_2_df["AT/NT"].to_string())
for index, row in interim_2_df.iterrows():
if str(interim_2_df["Stelle"]).find("Vgl.") != -1:
print(len(row["Zitat"]))
For that, I went on and tried to get the column "Stelle" and check whether "Vgl." occurs in it, but still, all lines of the quote are output, however only one should be output.
The csv looks like this:
Kuerzel;AT/NT;Stelle;Zitat;
Io_3,16-17;nt;Vgl. Joh 3,16f.;kein direktes Zitat;
Rm_3,9-20;nt;Vgl. Röm 3,9-20.;kein direktes Zitat;
Eph_1,7;nt;Vgl. Eph 1,7.;kein direktes Zitat;
Is_53,5-6;at;Vgl. Jes 53,5f.;kein direktes Zitat;
1Pt_2,24;nt;Vgl. 1 Petr 2,24.;kein direktes Zitat;
2Cor_5,19;nt;2 Kor 5,19.;was warhafftig inn Christo und versönet die welt mit im selber und rechnete inen ire sünden sünde. nicht zu unnd hat under uns auffgericht das wort von der versunung.;
Rm_3,25-26;nt;Vgl. Röm 3,25f.;kein direktes Zitat;
1Cor_1,29-31;nt;Vgl. 1 Kor 1,29-31.;kein direktes Zitat;
To be honest, I expected thi sor sth. similar to work, however it doesn't :-D
Solution
You may use:
interim_2_df[~ interim_2_df.Stelle.str.contains('Vgl')]
Output:
Kuerzel AT/NT Stelle Zitat
5 2Cor_5,19 nt 2 Kor 5,19. was warhafftig inn Christo und versönet die we...
Answered By - kelvt
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.