This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
string text = File.ReadAllText("MyFile.txt"); | |
// Do something with text |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
LastItemTracker<string> stringTracker = new(); | |
stringTracker.TrackItem("Hello"); | |
stringTracker.TrackItem("World"); | |
Console.WriteLine(stringTracker.LastItem); // Prints out "World" | |
bool isLastItem = stringTracker.IsLastItem("Hello"); // false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class LastItemTracker<T> | |
{ | |
public T LastItem {get; private set;} | |
public void TrackItem(T item) | |
{ | |
LastItem = item; | |
} | |
public bool IsLastItem(T item) | |
{ | |
return LastItem == item; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public string CombineTypes<T1, T2>(T1 firstType, T2 secondType) | |
{ | |
// Implementation omitted... | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
List<int> numbers = new() { 1, 2, 3}; | |
int[] intResults = BuildFirstLastArray<int>(numbers); | |
List<string> names = new() { "Priya", "Mohammed", "Alexis" }; | |
string[] strResults = BuildFirstLastArray<string>(names); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public T[] BuildFirstLastArray<T>(List<T> input) | |
{ | |
T[] result = new T[2](); | |
// For ease of readability, let's just use LINQ here | |
result[0] = input.First(); | |
result[1] = input.Last(); | |
return result; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public string[] BuildFirstLastArray(List<string> input) | |
{ | |
string[] result = new string[2](); | |
// For ease of readability, let's just use LINQ here | |
result[0] = input.First(); | |
result[1] = input.Last(); | |
return result; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public int[] BuildFirstLastArray(List<int> input) | |
{ | |
int[] result = new int[2](); | |
// For ease of readability, let's just use LINQ here | |
result[0] = input.First(); | |
result[1] = input.Last(); | |
return result; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
# CSV file is not relevant, just assuming you have some pre-existing data | |
df = pd.read_csv('models.csv') | |
# Define columns to add with an array of values for the new row(s) | |
data = { | |
"Model":["Linear Regression"], | |
"R2": [0.042], | |
"MSE": [3.14], |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
df = pd.concat([df_new_rows, df]) |