Based off this pandas get column average/mean
I can create a simple calculated field like this: My Query
df = pd.read_sql("select range_start, range_end from "+table+" group by range_start, range_end", conn)
creates this table:
Start Stop
4385159 4499467
4175786 4352309
342426 354137
5591040 5600392
What I want to do is inject a column that has the diff which I can do by doing this:
df2['Diff'] = df2['Stop'] - df2['Start']
Now my table looks like this:
Start End Diff
4385159 4499467 114308
4175786 4352309 176523
342426 354137 11711
My problem is how do I write a query that will return results:
df = pd.read_sql("select Diff from "+table+" where Diff < Xnumber group by Diff", conn)
I think I need to put a query inside of a query in jupyter (pandas). to do something like this:
df = pd.read_sql("select (df2['Stop'] - df2['Start']) as df2['Diff'] where (df2['Stop'] - df2['Start']) < Xnumber group by (df2['Stop'] - df2['Start'])",conn)
^ that didnt work but you get the idea