Skip to content

Instantly share code, notes, and snippets.

@sorindragan
Created October 13, 2019 14:46
Show Gist options
  • Save sorindragan/b29089806705e0f120c053876ec7aa94 to your computer and use it in GitHub Desktop.
Save sorindragan/b29089806705e0f120c053876ec7aa94 to your computer and use it in GitHub Desktop.
import pandas as pd
from sklearn.neighbors import KNeighborsRegressor
from sklearn.metrics import mean_squared_error
train = {'author': ['green', 'white'],
'age': [21, 34],
'pages': [100, 200],
}
train = pd.DataFrame(train)
print(train.head())
features = ['pages', 'age']
train_age = train.loc[train['age'].between(25, 34)]
print(train_age)
print(train_age[features])
for i, d in train.iterrows():
print(d[features])
age = d['age']
print(age)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment