1: Does the code run to completion without errors?
If there's an exception then the data may not get to the file because
I/O is normally buffered in memory and written out in larger chunks
as the buffer fills i.e. at a time later than your .writerow() call.
2: If you delete the CSV file
FOLLWOING IS MY CODE
import pandas as pd
import csv
from sklearn.preprocessing import LabelEncoder
from sklearn.feature_selection import chi2
with open("D:\PHD\obranking\\test_chi.csv", 'w') as csvfilew1:
fields = ['index', 'feature name', 'p_value']
csvwriter1 = csv.DictWriter(csvfilew1, f