0

I have a datatableof string values.one of the column name target attribute(that column will have maximum 4 different strings ,but all repeated in several rows,repetition of the four strings also not equal) is already known.I had found out which column number it has.again i have to find what are the string values in that column and how many times each string is repeated.
i had written the code successfully for getting two string values if it contains only two using following code
<CODE>
for (int n = 0; n < samples.Columns.Count; n++)
{
if (targetAttribute == samples.Columns[n].ColumnName)
{
classcolumn = n;
}

}
for (int d = 0; d < samples.Columns.Count; d++)
{
if (d == classcolumn)
{
for (int i = 0; i < samples.Rows.Count; i++)
{
value1 = samples.Rows[0][d].ToString();
if ((i != 0) && (samples.Rows[d].ToString() == value1))
{
value1_count++;
}
else if((i!=0) && (samples.Rows[d].ToString()!=value1))
{
value2 = samples.Rows[d].ToString();
value2_count++;
}

}
}
}</CODE>
But if 3 or 4 values,my idea is not working.how can I do it?

i will give an example
column named target has values as follows;

target
--------

yes
yes
no
true
yes
true
no
no
no
false
yes
true
false
no
this column is has 14 values.But the values of the column are unknown to us.so we have to find what are the strings in the column ie we should get yes, no, true,false and respective number of each string.
ie how many yes,how many no like that...

2
Contributors
3
Replies
4
Views
6 Years
Discussion Span
Last Post by Vayne
0

Can you please have more clarity in your question? Do you want to know how to retrieve values from a database? or do you want to know how to count the number distinct values?

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.