Question: I have a DataFrame like this:

```
df = pd.DataFrame(data= {'month' : [2,7,4,8], 'sales' : [10,40,70,50]})

```

I would like to get the sum of sales aggregated by the month. However, I want to have two groups of month combined, the first for months 1-6 (resulting in sales of 80) and the second for the months 7-12 (resulting in 90).

What's the best way to do this?

Answer: 
Are you using `Newtonsoft.Json`? I notice your code wouldn't work on .NET `System.Text.Json` since:

* There is no public non-generic version of `JsonConverter`.
* It wouldn't work on `id` because it's not a property.

Here's the working code for `System.Text.Json`:

```cs
public class HexConverter : JsonConverter<int>
{

    public override int Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
    {
        var value = reader.GetString();
        return Convert.ToInt32(value, 16);
    }

    public override void Write(Utf8JsonWriter writer, int value, JsonSerializerOptions options)
    {
        throw new NotImplementedException();
    }
}

```

The class has to contain properties to be deserialized:

```cs
public class Person
{

    public string name { get; set; }

    [JsonConverter(typeof(HexConverter))]
    public int id { get; set; }

}

```

Usage:

```cs
const string json = @"{
   ""name"" : ""someName"",
   ""id"" : ""b1""
}";

var person = JsonSerializer.Deserialize<Person>(json, new JsonSerializerOptions());

Console.WriteLine(person!.id);
// Result: 177

```

This case `Convert.ToInt32` works for me, but you can also use `int.Parse` as suggested in the other answer.
Try following Command to Convert a Hex-Number to an int

```
var hex = "b1"
int intValue = int.Parse(hex, System.Globalization.NumberStyles.HexNumber);

```