Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or 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
| from sklearn.preprocessing import LabelEncoder | |
| import pandas as pd | |
| import bisect | |
| le = LabelEncoder() | |
| train_c = le.fit_transform(['a', 'b', 'c', 'a']) | |
| test_c = pd.Series(['a', 'b', 'c', 'd']).map( | |
| lambda s: '<unk>' if s not in le.classes_ else s | |
| ) |
This file contains hidden or 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
| from sklearn.preprocessing import LabelEncoder | |
| import pandas as pd | |
| import bisect | |
| le = LabelEncoder() | |
| train_c = le.fit_transform(['a', 'b', 'c', 'a']) | |
| test_c = pd.Series(['a', 'b', 'c', 'd']).map( | |
| lambda s: '<unk>' if s not in le.classes_ else s | |
| ) |
This file contains hidden or 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
| from sklearn.preprocessing import LabelEncoder | |
| import pandas as pd | |
| import bisect | |
| le = LabelEncoder() | |
| train_c = le.fit_transform(['a', 'b', 'c', 'a']) | |
| test_c = pd.Series(['a', 'b', 'c', 'd']).map(lambda s: '<unk>' if s not in le.classes_ else s) | |
| print(test_c.tolist()) # ['a', 'b', 'c', '<unk>'] |
This file contains hidden or 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
| # Get everything! handles every single possible select query required | |
| # by the app.. | |
| # note: field_map is not the nicest thing in the world.. | |
| # it should be replaced by something wiser sometime! | |
| def query(g, params, tables, query_fields=None, query_op='ilike', what='*', | |
| join=None, where=None, field_map=None, group_by=None, order_by=None, | |
| include_total=True, debug=False): | |
| if query_fields is None: | |
| query_fields = () | |
| if join is None: |
This file contains hidden or 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
| import qualified Data.Sequence as Sequence | |
| fromList = Sequence.fromList | |
| index = Sequence.index | |
| update = Sequence.update | |
| data Color = Red | | |
| Green | | |
| Blue | | |
| Yellow |
This file contains hidden or 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
| @app.route('/upload_data', methods=['POST']) | |
| def upload_data(): | |
| cur = conn.cursor() | |
| f = request.files['file'] | |
| df = pd.DataFrame.from_csv(f, index_col=False) | |
| df.hashtags = df.hashtags.map(ast.literal_eval) | |
| screen_name = df.screen_name.unique() | |
| assert len(screen_name) == 1 | |
| screen_name = screen_name[0] | |
| cur.execute('delete from tweets where screen_name = %s', [screen_name]) |
This file contains hidden or 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
| - name: Run whoami to get ssh user | |
| command: whoami | |
| register: whoami_output | |
| - name: Set user fact | |
| set_fact: | |
| user: "{{ whoami_output.stdout }}" | |
| - name: test it! | |
| debug: msg="{{ user }}" # should be vagrant on a VM, or your remote user for whatever else |