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
### MATPLOTLIBRC FORMAT | |
# This is a sample matplotlib configuration file - you can find a copy | |
# of it on your system in | |
# site-packages/matplotlib/mpl-data/matplotlibrc. If you edit it | |
# there, please note that it will be overridden in your next install. | |
# If you want to keep a permanent local copy that will not be | |
# over-written, place it in HOME/.matplotlib/matplotlibrc (unix/linux | |
# like systems) and C:\Documents and Settings\yourname\.matplotlib | |
# (win32 systems). |
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 xml import sax | |
class XMLParser(sax.handler.ContentHandler): | |
def __init__(self, keys=[], lists=[], *args, **kwargs): | |
""" | |
:param keys: list of data keys have to be available in data | |
:param lists: list of nodes have be represented as list |
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 urllib.request import urlopen | |
from xml.etree.ElementTree import parse | |
# Download the RSS feed and parse it | |
u = urlopen('http://planet.python.org/rss20.xml') | |
doc = parse(u) | |
# Extract and output tags of interest | |
for item in doc.iterfind('channel/item'): | |
title = item.findtext('title') |
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
// XPath CheatSheet | |
// To test XPath in your Chrome Debugger: $x('/html/body') | |
// http://www.jittuu.com/2012/2/14/Testing-XPath-In-Chrome/ | |
// 0. XPath Examples. | |
// More: http://xpath.alephzarro.com/content/cheatsheet.html | |
'//hr[@class="edge" and position()=1]' // every first hr of 'edge' class |
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
## | |
# Create a figure space matrix consisting of 3 columns and 2 rows | |
# | |
# Here is a useful template to use for working with subplots. | |
# | |
################################################################## | |
fig, ax = plt.subplots(figsize=(10,5), ncols=3, nrows=2) | |
left = 0.125 # the left side of the subplots of the figure | |
right = 0.9 # the right side of the subplots of the figure |
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
# --------------------------------------------------------- | |
# library imports. | |
import numpy as np | |
import pandas as pd | |
from matplotlib import pyplot as plt | |
from matplotlib.dates import DateFormatter, DayLocator, HourLocator | |
# ********************************************************* |
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
# List unique values in a DataFrame column | |
df['Column Name'].unique() # Note, `NaN` is included as a unique value. If you just want the number, use `nunique()` which stands | |
# for 'number of unique values'; By default, it excludes `NaN`. `.nunique(dropna=False)` will include `NaN` in the count of unique values. | |
# To extract a specific column (subset the dataframe), you can use [ ] (brackets) or attribute notation. | |
df.height | |
df['height'] | |
# are same thing!!! (from http://www.stephaniehicks.com/learnPython/pages/pandas.html | |
# -or- | |
# http://www.datacarpentry.org/python-ecology-lesson/02-index-slice-subset/) |
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
<?xml version="1.0" encoding="UTF-8"?> | |
<module type="PYTHON_MODULE" version="4"> | |
<component name="NewModuleRootManager"> | |
<content url="file://$MODULE_DIR$" /> | |
<orderEntry type="inheritedJdk" /> | |
<orderEntry type="sourceFolder" forTests="false" /> | |
</component> | |
<component name="TestRunnerService"> | |
<option name="PROJECT_TEST_RUNNER" value="Unittests" /> | |
</component> |
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 requests | |
import xml.etree.ElementTree as ET | |
url = 'http://test.cognizant.e-box.co.in/uploads/data_usage.xml' | |
# Getting the xml data from url | |
req = requests.get(url) | |
text = req.text | |
# Parsing the xml | |
root = ET.fromstring(text) |
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 gensim.utils import smart_open | |
from collections import defaultdict, OrderedDict | |
import csv | |
import xml.etree.ElementTree as ET | |
headers = ['AcceptedAnswerId', 'AnswerCount', 'ClosedDate', 'CommentCount', 'CommunityOwnedDate', 'CreationDate', | |
'FavoriteCount', 'Id', 'LastActivityDate', 'LastEditDate', 'LastEditorDisplayName', 'LastEditorUserId', | |
'OwnerDisplayName', 'OwnerUserId', 'ParentId', 'PostTypeId', 'Score', 'Tags', 'Title', 'ViewCount'] | |
file_path = "" |
OlderNewer