Quantcast
Channel: Active questions tagged row - Stack Overflow
Viewing all articles
Browse latest Browse all 513

DataFrame Filter Row keeps Saying "string" to "int" even though no "int"

$
0
0

I am currently creating a filter for a DataFrame that is supposed to filter out string based upon a list of strings I don't want in the column.

The Column when I look at the DataFrame says that it is in-fact System.String data type.

However, what puzzles me the most is that I recieve the error, even though it doesn't know what the column would be since it doesn't directly reference the DataFrame. The error I receive is the following :

Argument 1: cannot convert from 'string' to 'int'RoslynCS1503class System.StringRepresents text as a sequence of UTF-16 code units.

It says this error highlighting the "stringcolumn" section when I declare row["stringcolumn"].

// Load the data into the data framevar dataFrame = DataFrame.LoadCsv(dataPath);// To get a preview of the column datatypes, run Info().Console.WriteLine(dataFrame.Info());// To get a summary of the data, run Description().Console.WriteLine(dataFrame.Description());// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~// Removing the unwanted String Rows// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~// Creating a list of bad strings to remove from the original data frameList<string> stringsToRemove = new List<string> {"string123", "stringabc"};// Define the filter condition: Define a delegate that takes a DataFrameRow and returns true// if the row should be included in the output DataFrame and false otherwise. This delegate is // invoked for each row in the DataFrame.// Func<DataFrameRow, bool> filterCondition = row => !stringsToRemove.Contains(row.GetAs<string>("stringcolumn"));// Func<DataFrameRow, bool> filterCondition = row => !stringsToRemove.Contains((string)row["stringcolumn"]);Func<DataFrameRow, bool> filterCondition = row =>{    string badString = row["stringcolumn"].ToString(); // Access the serialnumber value from the row    return !stringsToRemove.Contains(badString);};

You can see I have tried other methods, and they return the same result. I'm currently using VS Code as my IDE.

I was expecting it to remove the serial numbers, however all references state that this is the proper way to format this, and I don't understand why VS code says it's bad, since how could it possibly check for a string if it doesn't even have reference to the DataFrame column in that filter?


Viewing all articles
Browse latest Browse all 513

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>