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)?

0

2 Answers 2

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.

Sign up to request clarification or add additional context in comments.

1 Comment

It works! thank you!
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

1 Comment

It works! thank you!

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.