A small, complete example of the issue

# Your code here
# -*- coding: utf-8 -*-
import pandas as pd
from pandas import DataFrame

f = pd.read_excel('./123.xlsx',index_col = None)
f2 = pd.DataFrame()
for i in range(0,len(f)):
    f2.loc[i,'Term'] = f.loc[i,'Term']
    if f.loc[i,'P-value'] <= 0.05:
        for gene in f.loc[i,'Genes'].split(';'):
            f2.loc[i,gene] = 1
f2.fillna(0,inplace = True)
f2.to_csv('./123.csv',index = False)

Expected Output

Output of pd.show_versions()

the input file Term gene ABCD (ZXCV) gene1,gene2,gene3 the output file f2['Term'] include space and '()' example: f2.loc[0,'Term'] = ABCD (ZXCV) the csv file it output is Term gene1 ABCD (ZXCV) ' (123)' come to the 'gene1' columns and cover the existing data,example(which i wanted): Term gene1 ABCD 1

Comment From: jreback

pls start with a created dataframe (by code) and not a file which you didn't' provide.

further actually show pd.show_versions()

Comment From: junjieahaha

Thankyouforreplay