Skip to content

Instantly share code, notes, and snippets.

@bchirico
bchirico / Reuters.py
Created November 14, 2015 08:42 — forked from herrfz/Reuters.py
Reuters-21578 keyword extraction
# Reuters-21578 dataset downloader and parser
#
# Author: Eustache Diemert <eustache@diemert.fr>
# http://scikit-learn.org/stable/auto_examples/applications/plot_out_of_core_classification.html
#
# Modified by @herrfz, get pandas DataFrame from the orig SGML
# License: BSD 3 clause
from __future__ import print_function
@bchirico
bchirico / django
Last active August 29, 2015 14:23
Django
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Django</title>
<link rel="stylesheet" href="https://stackedit.io/res-min/themes/base.css" />
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"></script>
</head>
<body><div class="container"><p><div class="toc">
<ul>
@bchirico
bchirico / django.md
Last active June 9, 2016 18:55
Django

[TOC]

MVC in Django

Ci sono un elevato numero di funzioni che possono essere usate per facilitare e modularizzare compiti “standard”.

  • interazione con db
  • autenticazione
  • etc
@bchirico
bchirico / pom.xml
Last active August 29, 2015 14:17 — forked from ggrandes/pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.acme</groupId>
<artifactId>bomb</artifactId>
<version>0.0.1</version>
<packaging>war</packaging>
<name>bomb</name>
<dependencies>
<dependency>
<div ng-app="videoApp" ng-controller="VideoController">
<table>
<thead>
<th>Title</th>
<th>Length</th>
<th></th>
</thead>
<tbody>
<tr data-id="{{video.Id}}" ng-repeat="video in videos">
@bchirico
bchirico / pandas_installation.md
Created November 30, 2013 14:39
Installation guide for pandas

##Pandas installation

###Pandas sudo apt-get install python-pandas

###Dependencies ####Numpy sudo pip install numpy ####python-dateutil ####pytz

@bchirico
bchirico / movielens.py
Created November 30, 2013 13:09
Python for data analysis - chapter 2 - example
import pandas as pd
unames = ['user_id', 'gender', 'age', 'occupation', 'zip']
users = pd.read_table('users.dat', sep='::', header=None,
names=unames)
rnames = ['user_id', 'movie_id', 'rating', 'timestamp']
ratings = pd.read_table('ratings.dat', sep='::', header=None,
names=rnames)
mnames = ['movie_id', 'title', 'genres']
movies = pd.read_table('movies.dat', sep='::', header=None,
names=mnames)
@bchirico
bchirico / usagov.py
Created November 30, 2013 11:53
Python for data analysis - chapter 2 - example
import json
from pandas import DataFrame, Series
import pandas as pd
path = 'usagov_bitly_data2012-03-16-1331923249.txt'
records = [json.loads(line) for line in open(path)]
time_zones = [rec['tz'] for rec in records if 'tz' in rec]
frame = DataFrame(records)
clean_tz = frame['tz'].fillna('Missing')
clean_tz[clean_tz == ''] = 'Unknown'