首页 > 代码库 > Statistics and Linear Algebra 6

Statistics and Linear Algebra 6

1. Two ways to get a column of another column with max/min values:

  a. most_bars_country = flags["name"][flags["bars"].idxmax()]

  b. bars_sorted = flags.sort_values("bars", ascending=[0])

    most_bars_country = bars_sorted["name"].iloc[0]

2. The way to get the probability of a certain value in a column:

  orange_probability = flags[flags["orange"]==1].shape[0]/flags.shape[0]

3. The way to calculate combination by using factorial 

  import math
  def find_outcome_combinations(N, k): # Calculate the numerator of our formula.
    numerator = math.factorial(N) # Calculate the denominator.
    denominator = math.factorial(k) * math.factorial(N - k) # Divide them to get the final value.
    return numerator / denominator

4. 

Statistics and Linear Algebra 6