-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathperiod_ratios.py
29 lines (20 loc) · 870 Bytes
/
period_ratios.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import pandas
exoplanet_filtereddata_multiplanet_sorted = pandas.read_csv('exoplanet_filtereddata_multiplanet_sorted.csv')
df = pandas.DataFrame(exoplanet_filtereddata_multiplanet_sorted)
df['KOI_integer'] = df['KOI'].astype(str).str.split('.').str[0].astype(int)
result = []
for _, group in df.groupby('KOI_integer'):
for i in range(1, len(group)):
row_inner = group.iloc[i - 1]
row_outer = group.iloc[i]
period_ratio = row_outer['Period'] / row_inner['Period']
result.append({
'KOI_inner': row_inner['KOI'],
'Period_inner': row_inner['Period'],
'KOI_outer': row_outer['KOI'],
'Period_outer': row_outer['Period'],
'Period Ratios': period_ratio
})
df_ratio = pandas.DataFrame(result)
print(df_ratio)
df_ratio.to_csv('exoplanet_multiplanetsystem_ratios.csv')