0

Currently I have a csv file in which the last column, which we can refer to as label, is empty. Here is a picture of the data: enter image description here

I get predictions through a classifier:

[0.  1.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  1.  1.  1.  0.  0.  0.]

Thus my question is how to write these predictions into the last column (label)?

Moinuddin Quadri
  • 46,825
  • 13
  • 96
  • 126
曾逸飞
  • 23
  • 1
  • 5

2 Answers2

1

Potentially one of the easiest solutions would be to read your data in using pandas.

my_dataframe = pandas.read_csv("filename")

Then assuming your label column is some kind of list/array or even pandas series, you can simply enter

my_dataframe["label"] = my_label_list

subsequently you write back your pandas dataframe using

my_dataframe.to_csv("filename_out")

NOTE: I omitted additional parameter arguments for reading and writing the csv, you can google and read the docs and add them as you see fit.

meow
  • 2,062
  • 2
  • 17
  • 27
0

You should read your data from csv file without the last column

df = pd.DataFrame(data, columns = ['domain_name_length', 'domain_name_enthropy', 'digit_num', 'alpha_num', 'delimiter_num', 'special_num','max_conitous_digit_length','max_conitous_alpha_length','max_length_between_delimeter'])

Than just add your column

df['labels'] = labels
Richard Rublev
  • 7,718
  • 16
  • 77
  • 121