Hello, I'm a beginner who just started playing pandas. I'm a python. It's just that I'm making a df in Dataframe that contains certain words, and that particular word gets some value from the array.
arrayBut I need to make double for statements that fit the arrangement of df one by one, but is there a way to make multiple for statements or other df with the code I made in the example below?
Please give us good suggestions.
trp1 = df[(df['ITEM'].str.contains(pat[0])) & (df['ITEM'].str.contains(mux[0]))].astype(float)
trp2 = df[(df['ITEM'].str.contains(pat[0])) & (df['ITEM'].str.contains(mux[1]))].astype(float)
trp3 = df[(df['ITEM'].str.contains(pat[0])) & (df['ITEM'].str.contains(mux[2]))].astype(float)
trp4 = df[(df['ITEM'].str.contains(pat[0])) & (df['ITEM'].str.contains(mux[3]))].astype(float)
trp5 = df[(df['ITEM'].str.contains(pat[0])) & (df['ITEM'].str.contains(mux[4]))].astype(float)
pandas dataframe
trps=[]
for _ in [1,2,3,4,5]:
tmp = df[(df['ITEM'].str.contains(pat[0])) & (df['ITEM'].str.contains(mux[_]))].astype(float)
trps.append(tmp)
© 2024 OneMinuteCode. All rights reserved.