Q: Trying to calculate a percentage rank to each row based on type(which is a column with around 10 unqiue string) I have a data frame of over a million rows with a sample structure like this: 

ID Type Value1 Value2... (more columns)
1  A    20    4 ...
2  A    30    5 ...
3  B    14    7...
4  B    12    9...
.....

I hope I could get 

ID Type Value1 Value2 Pct_Rank_based_on_Value1 ... (more columns)
1  A    20    4  0.107 ...
2  A    30    5  0.021 ...
3  B    14    7  0.201 ...
4  B    12    9  0.875 ...

.....

rank should be in decreasing order of value. The max should have a value near 0.001

And for clarification, my purpose is to create a new column which is the percentage ranking of a row's Value1 (which is a column of discrete numbers) within itsType (which is a column of strings, only 10 unique values). 
For row 1, ID is 1, Type is A, Value is 20, I'd like to compute its pct rank of Value1 within those rows whose Type is also A. 


*

*I have checked a few post's implementations and I am thinking of using 
df['Pct_Rank'] = pd.DataFrame(df.groupby("Type").index.get_level_values('Value1').rank(pct = True)
But I'm not sure if it is correct.

*I thought about create sub-dataframes with each types and sort them based on Value1, but how to search the position for each row's Values in its corresponding type? After that I could write a func and apply to each row, computing its pct rank by 

increment_type_A = 1/lengthA
....
if type == A:
pct_rank = increment_typeA * position_in_its_type
.......

By the way, is there any parameters to set the pct? like the precision? I want something like 0.001 at least. 
Updates
I just reformatted my sample. The table was messed up after I select them and choose "bold". 
Just edited to clarify that has more than 1 number-valued column. And Value1 is not the first column with number-value.

A: If I've understood the question correctly, this should work:
from pandas import DataFrame
df = DataFrame([['A', 20, 1], ['A', 30, 2], ['B', 14, 1], ['B', 12, 6]], columns=['Type', 'Value1', 'Value2'])
df['pct_rank'] = df.groupby('Type').rank(axis=0, pct=True, ascending=False)['Value1']

