jkushwaha commited on
Commit
a63b001
·
verified ·
1 Parent(s): 22295d9

Update tmp.py

Browse files
Files changed (1) hide show
  1. tmp.py +20 -1
tmp.py CHANGED
@@ -1,3 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  labels = [f'{int(bins[i])}-{int(bins[i+1])}' for i in range(len(bins)-1)] # Labels: 0-20, 20-40, ..., 80-100
2
 
3
  # Assign each percentile to a bin, including the right edge of the last bin
@@ -6,4 +25,4 @@ percentile_df['Percentile Bin'] = pd.cut(percentile_df['Percentile'], bins=bins,
6
  # Aggregate values by percentile bin
7
  percentile_bins_summary = percentile_df.groupby('Percentile Bin')['Value'].agg(['min', 'max', 'mean', 'count'])
8
 
9
- print(percentile_bins_summary)
 
1
+ import pandas as pd
2
+ import numpy as np
3
+
4
+ # Assuming df is your DataFrame
5
+ # Filter the DataFrame to include only rows where 'Lab Name' is 'NeoGenomics Laboratories'
6
+ filtered_df = df[df['Lab Name'] == 'NeoGenomics Laboratories']
7
+
8
+ # Group by 'pif_key' and count 'Biomarker Name Source'
9
+ grouped_counts = filtered_df.groupby('pif_key')['Biomarker Name Source'].count()
10
+
11
+ # Calculate percentiles from 0 to 100
12
+ percentiles = np.linspace(0, 100, 101)
13
+ percentile_values = np.percentile(grouped_counts, percentiles)
14
+
15
+ # Create a DataFrame to display percentiles
16
+ percentile_df = pd.DataFrame({'Percentile': percentiles, 'Value': percentile_values})
17
+
18
+ # Define 5 percentile bins for intervals: 0-20, 20-40, 40-60, 60-80, 80-100
19
+ bins = np.linspace(0, 100, 6) # Bins will be: 0, 20, 40, 60, 80, 100
20
  labels = [f'{int(bins[i])}-{int(bins[i+1])}' for i in range(len(bins)-1)] # Labels: 0-20, 20-40, ..., 80-100
21
 
22
  # Assign each percentile to a bin, including the right edge of the last bin
 
25
  # Aggregate values by percentile bin
26
  percentile_bins_summary = percentile_df.groupby('Percentile Bin')['Value'].agg(['min', 'max', 'mean', 'count'])
27
 
28
+ print(percentile_bins_summary)