Skip to content

Instantly share code, notes, and snippets.

@iprocheta
Last active December 9, 2017 14:27
Show Gist options
  • Select an option

  • Save iprocheta/4cfd4cc9d078925a3e84720201f27b48 to your computer and use it in GitHub Desktop.

Select an option

Save iprocheta/4cfd4cc9d078925a3e84720201f27b48 to your computer and use it in GitHub Desktop.
column comparisn
Display the source blob
Display the rendered blob
Raw
data = pd.read_csv('E:\\training.csv')
array3 = data['Cholesterol medicine years'].replace(np.Nan,-1)
length = array3.shape[0]
print(length)
arr3 = [];
for i in range(length):
if array3[i] != -1:
# print(i)
arr3.append(array[i])
print(arr3)
trimmed = st.trim_mean(arr3,.05)
mask=(data['Cholesterol']=='Yes') & ((data['Cholesterol medicine years'=='NA']) |(data['Cholesterol medicine years'=='No']|(data['Cholesterol medicine years'=='VALID']))
data.loc[mask,'Cholesterol medicine years']=pd.to_numeric(data['Cholesterol medicine years'],errors='coerce').fillna(trimmed)
data.to_csv(r'E:\\data.csv')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment