View basement_select.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
conditions = [ | |
(temp['calc_basement'] == 0), | |
(temp['calc_basement'] > 0) & (temp['calc_basement'] <= 300), | |
(temp['calc_basement'] > 300) & (temp['calc_basement'] <= 600), | |
(temp['calc_basement'] > 600) & (temp['calc_basement'] <= 1000), | |
(temp['calc_basement'] > 1000) & (temp['calc_basement'] <= 5000), | |
] | |
values = ['level_1', 'level_2', 'level_3', 'level_4','level_5'] | |
View basement_where.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
temp['has_basement'] = np.where(temp['calc_basement'] == 0, False, True) | |
temp.head() |
View renovation.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
df['renovation'] = df['yr_renovated'].fillna(pd.Series(np.random.choice([999, 0], | |
p=[744/17011, 1-(744/17011)], | |
size=len(df)))) | |
View waterfront_values.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
print("Value counts for waterfront: \n{}".format(df.waterfront.value_counts())) | |
print("\nTotal waterfront values: {}".format(len(df.waterfront))) |
View wrong_drop.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
df.waterfront.dropna(axis=0,inplace=True) |
View gist:cc724a377c400b4cd874d1137db6f26d
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Create df with zip code as index and mean latitude value for each zip code | |
no_index_zip_lat = df.groupby('zipcode', as_index=True)['lat'].mean() | |
# Convert the data frame to a dict, the zip is the key and mean latitude is the value | |
zip_lat_dict = no_index_zip_lat.to_dict() |
View gist:d90c83cdcf05fa37603db366f8290ecd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This combines the two operations: find digits in the string and find the two numbers that equal 10 | |
def sum_finder(test): | |
target = 10 | |
success = [] | |
result = [int(i) for i in test if i.isdigit()] | |
for i in range(0, len(result)-1): | |
num_sum = (result[i] + result[i+1]) |
View gist:231dd4f5fffe7e3d3c6e81a07e1880c5
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def split(text): | |
return [char for char in text] |
View gist:f4b8c7788fe871266d98a0312162e462
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def char_test(sample): | |
# Call function to see if there are two numbers that add to 10 in the text string | |
success = sum_finder(sample) | |
# Check to see if success (the return is empty or not) | |
if not success: | |
print("False") | |
else: |
View bracket_matcher_v1.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def bracket_matcher(sample): | |
for char in sample: | |
if char == ')': | |
print('True') | |
else: | |
print('False') |
OlderNewer