I have written some code to extract data in pandas, however i am getting true and false values and not the ouput
extract data using groupby pandas
import pandas as pd df = pd.read_csv("All.csv",encoding="ISO-8859-1") CLO= df.groupby("CLO") df1=(df['CLO'].str.match("xxxx")) df1.to_csv("AE.csv")
Input file
CLO Name Points Fund AE 100 ABSA ME 50 FNB AE 200 SB MY 300 NED
Output file should look like
CLO Name Points Fund AE 100 ABSA AE 200 SB
Output file looks like
1. True 2. False 3. True
Goes on like this up to last line of data in input file
Advertisement
Answer
import pandas as pd
df = pd.read_csv(“All.csv”,encoding=”ISO-8859-1″) CLO=df.groupby(“CLO”)
AE=(CLO.get_group(“xxxx”))
AE.to_csv(“AE1.csv”,index=False)