Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Microsoft.Data.Analysis/DataFrame.BinaryOperators.tt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ namespace Microsoft.Data.Analysis
{
public partial class DataFrame
{
#pragma warning disable 1591
#pragma warning disable 1591
<# foreach (MethodConfiguration method in methodConfiguration) { #>
<# if (method.MethodType == MethodType.BinaryScalar) { #>
<# if (method.IsBitwise == true) { #>
Expand All @@ -32,7 +32,7 @@ namespace Microsoft.Data.Analysis
{
return df.<#=method.MethodName#>(value);
}

public static DataFrame operator <#=method.Operator#>(<#=type.TypeName#> value, DataFrame df)
{
return df.Reverse<#=method.MethodName#>(value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ namespace Microsoft.Data.Analysis
{
public abstract partial class DataFrameColumn
{
#pragma warning disable 1591
#pragma warning disable 1591
<# foreach (MethodConfiguration method in methodConfiguration) { #>
<# if (method.MethodType == MethodType.BinaryScalar) { #>
<# if (method.IsBitwise == true) { #>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ namespace Microsoft.Data.Analysis
{
<# foreach (MethodConfiguration method in methodConfiguration) { #>
<# if (method.MethodType == MethodType.Comparison || method.MethodType == MethodType.ComparisonScalar) { #>
public <#= method.GetSingleArgumentMethodSignature("PrimitiveColumnContainer", "T") #>
{
public <#= method.GetSingleArgumentMethodSignature("PrimitiveColumnContainer", "T") #>
{
<# if (method.MethodType == MethodType.ComparisonScalar ) { #>
PrimitiveDataFrameColumnArithmetic<T>.Instance.<#=method.MethodName#>(this, scalar, ret);
<# } else { #>
PrimitiveDataFrameColumnArithmetic<T>.Instance.<#=method.MethodName#>(this, right, ret);
<# } #>
return this;
}
}

<# } else { #>
public <#= method.GetSingleArgumentMethodSignature("PrimitiveColumnContainer", "T")#>
Expand All @@ -45,11 +45,11 @@ namespace Microsoft.Data.Analysis
<# } #>
<# foreach (MethodConfiguration method in methodConfiguration) { #>
<# if (method.MethodType == MethodType.BinaryScalar) { #>
public PrimitiveColumnContainer<T> Reverse<#=method.MethodName#>(T scalar)
{
public PrimitiveColumnContainer<T> Reverse<#=method.MethodName#>(T scalar)
{
PrimitiveDataFrameColumnArithmetic<T>.Instance.<#=method.MethodName#>(scalar, this);
return this;
}
}
<# } #>
<# } #>
}
Expand Down
4 changes: 2 additions & 2 deletions src/Microsoft.Data.Analysis/PrimitiveDataFrameColumn.cs
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ public override double Median()
PrimitiveDataFrameColumn<long> sortIndices = GetAscendingSortIndices(out Int64DataFrameColumn _);
long middle = sortIndices.Length / 2;
double middleValue = (double)Convert.ChangeType(this[sortIndices[middle].Value].Value, typeof(double));
if (Length % 2 == 0)
if (sortIndices.Length % 2 == 0)
{
double otherMiddleValue = (double)Convert.ChangeType(this[sortIndices[middle - 1].Value].Value, typeof(double));
return (middleValue + otherMiddleValue) / 2;
Expand All @@ -243,7 +243,7 @@ public override double Mean()
{
if (Length == 0)
return 0;
return (double)Convert.ChangeType((T)Sum(), typeof(double)) / Length;
return (double)Convert.ChangeType((T)Sum(), typeof(double)) / (Length - NullCount);
}

protected internal override void Resize(long length)
Expand Down
Loading