text stringlengths 0 1.05M | meta dict |
|---|---|
"""2D and 3D vector classes.
These are used to represent points in 2D and 3D, as well as directions for translations.
"""
from typing import Any, Iterable, Iterator, List, Optional, Sized, Tuple, Union # noqa
import numpy as np
from six.moves import zip
if False:
from .polygons import Polygon3D # noqa
class... | {
"repo_name": "jamiebull1/geomeppy",
"path": "geomeppy/geom/vectors.py",
"copies": "1",
"size": "6139",
"license": "mit",
"hash": -1382481578784702200,
"line_mean": 29.0931372549,
"line_max": 117,
"alpha_frac": 0.5541619156,
"autogenerated": false,
"ratio": 3.615429917550059,
"config_test": fal... |
## 2. Data cleaning ##
import pandas as pd
columns = ["mpg", "cylinders", "displacement", "horsepower", "weight", "acceleration", "model year", "origin", "car name"]
cars = pd.read_table("auto-mpg.data", delim_whitespace=True, names=columns)
filtered_cars = cars[cars['horsepower']!='?']
filtered_cars['horsepower'] = f... | {
"repo_name": "vipmunot/Data-Analysis-using-Python",
"path": "Machine learning Beginner/Challenge_ Machine Learning Basics-205.py",
"copies": "1",
"size": "1179",
"license": "mit",
"hash": 7889563487431483000,
"line_mean": 31.7777777778,
"line_max": 122,
"alpha_frac": 0.7048346056,
"autogenerated":... |
"""2D backpropagation algorithm"""
import numpy as np
import scipy.ndimage
from . import util
def backpropagate_2d(uSin, angles, res, nm, lD=0, coords=None,
weight_angles=True,
onlyreal=False, padding=True, padval=0,
count=None, max_count=None, verbose=0... | {
"repo_name": "paulmueller/ODTbrain",
"path": "odtbrain/_alg2d_bpp.py",
"copies": "2",
"size": "11346",
"license": "bsd-3-clause",
"hash": -6058115727231118000,
"line_mean": 33.463190184,
"line_max": 77,
"alpha_frac": 0.5732977303,
"autogenerated": false,
"ratio": 3.28029197080292,
"config_test... |
"""2D canvas style graphics functionality backed by Qt's QGraphicsView."""
from PyQt5 import QtCore, QtGui, QtWidgets
class Canvas(QtWidgets.QGraphicsView):
"""A 2D canvas interface implemented using a QGraphicsView.
This view essentially just holds a QGraphicsScene that grows to fit the
size of the vie... | {
"repo_name": "ucdrascal/hcibench",
"path": "axopy/gui/canvas.py",
"copies": "2",
"size": "10191",
"license": "mit",
"hash": -1388182486694122800,
"line_mean": 29.150887574,
"line_max": 79,
"alpha_frac": 0.6024923953,
"autogenerated": false,
"ratio": 3.8283245679939895,
"config_test": false,
... |
# 2D channel example
# ==================
#
# .. highlight:: python
#
# This example demonstrates a depth-averaged 2D simulation in a closed
# rectangular domain, where the flow is forced by an initial pertubation in the
# water elevation field.
#
# We begin by importing Thetis and creating a rectangular mesh with :... | {
"repo_name": "tkarna/cofs",
"path": "demos/demo_2d_channel.py",
"copies": "2",
"size": "3870",
"license": "mit",
"hash": 5646640883570143000,
"line_mean": 34.504587156,
"line_max": 127,
"alpha_frac": 0.719379845,
"autogenerated": false,
"ratio": 3.1695331695331697,
"config_test": false,
"has... |
# 2D channel with time-dependent boundary conditions
# ==================================================
#
# .. highlight:: python
#
# Here we extend the :doc:`2D channel example <demo_2d_channel.py>` by adding constant and time
# dependent boundary conditions.
#
# We begin by defining the domain and solver as befo... | {
"repo_name": "tkarna/cofs",
"path": "demos/demo_2d_channel_bnd.py",
"copies": "2",
"size": "3996",
"license": "mit",
"hash": -4719998112690868000,
"line_mean": 35,
"line_max": 101,
"alpha_frac": 0.7187187187,
"autogenerated": false,
"ratio": 3.256723716381418,
"config_test": false,
"has_no_k... |
# 2D Discrete Fourier Transform (DFT) and its inverse
# Warning: Computation is slow so only suitable for thumbnail size images!
# FB - 20150102
from PIL import Image
import cmath
pi2 = cmath.pi * 2.0
def DFT2D(image):
global M, N
(M, N) = image.size # (imgx, imgy)
dft2d_red = [[0.0 for k in range(M)] for ... | {
"repo_name": "ActiveState/code",
"path": "recipes/Python/578997_2D_Discrete_Fourier_Transform/recipe-578997.py",
"copies": "1",
"size": "2049",
"license": "mit",
"hash": -5047564682141014000,
"line_mean": 34.9473684211,
"line_max": 85,
"alpha_frac": 0.4782820888,
"autogenerated": false,
"ratio":... |
# 2 DECIMAL POINT
#9-3-17
# Initialize resistor colors
BLACK = ['black', 0, 0, 0, 1, None]
BROWN = ['brown', 1, 1, 1, 10, "1%"]
RED = ['red', 2, 2, 2, 100, "2%"]
ORANGE = ['orange', 3, 3, 3, 1000, "3%"]
YELLOW = ['yellow', 4, 4, 4, 10000, "4%"]
GREEN = ['green', 5, 5, 5, 100000, "0.5%"]
BLUE = ['blue', 6, 6, 6... | {
"repo_name": "dgaiero/Resistor-Band-Picture-Creator",
"path": "Test Scripts/resistorAlgorithm5Band.py",
"copies": "1",
"size": "4016",
"license": "mit",
"hash": 279273345368002000,
"line_mean": 37.6153846154,
"line_max": 102,
"alpha_frac": 0.6389442231,
"autogenerated": false,
"ratio": 3.2179487... |
## 2. Defining custom classes ##
print(header)
class Player():
# The special __init__ function is run whenever a class is instantiated.
# The init function can take arguments, but self is always the first one.
# Self is just a reference to the instance of the class. It is automatically
# passed in... | {
"repo_name": "vipmunot/Data-Analysis-using-Python",
"path": "Python Programming Advanced/Object-oriented programming-108.py",
"copies": "1",
"size": "7191",
"license": "mit",
"hash": -6317349503392777000,
"line_mean": 34.0829268293,
"line_max": 116,
"alpha_frac": 0.6136837714,
"autogenerated": fal... |
# 2D example of viewing aggregates from SA using VTK
from pyamg.aggregation import standard_aggregation
from pyamg.vis import vis_coarse, vtk_writer
from pyamg.gallery import load_example
from pyamg import *
from scipy import *
# retrieve the problem
data = load_example('unit_square')
A = data['A'].tocsr()
V = data['v... | {
"repo_name": "pombreda/pyamg",
"path": "Examples/WorkshopCopper11/task2.3.py",
"copies": "2",
"size": "1357",
"license": "bsd-3-clause",
"hash": 5867146414176847000,
"line_mean": 32.925,
"line_max": 77,
"alpha_frac": 0.6595431098,
"autogenerated": false,
"ratio": 3.3423645320197046,
"config_te... |
# 2D example of viewing aggregates from SA using VTK
from pyamg.aggregation import standard_aggregation
from pyamg.vis import vis_coarse, vtk_writer
from pyamg.gallery import load_example
# retrieve the problem
data = load_example('unit_square')
A = data['A'].tocsr()
V = data['vertices']
E2V = data['elements']
# perf... | {
"repo_name": "pombreda/pyamg",
"path": "Examples/VisualizingAggregation/demo1.py",
"copies": "1",
"size": "1224",
"license": "bsd-3-clause",
"hash": -5113691601155100000,
"line_mean": 33.9714285714,
"line_max": 77,
"alpha_frac": 0.6454248366,
"autogenerated": false,
"ratio": 3.5789473684210527,
... |
# 2D Fluid Simulation using FHP LGCA (Lattice Gas Cellular Automata)
# Simulates fluid flow in a circular channel.
# Particles go out from right side and enter back from left.
# Reference:
# Lattice Gas Cellular Automata and Lattice Boltzmann Models by Wolf-Gladrow
# FB - 20140818
import math
import random
from PIL imp... | {
"repo_name": "ActiveState/code",
"path": "recipes/Python/578924_2D_Fluid_Simulatiusing_FHP/recipe-578924.py",
"copies": "1",
"size": "8116",
"license": "mit",
"hash": 808702404464751400,
"line_mean": 35.7239819005,
"line_max": 86,
"alpha_frac": 0.4499753573,
"autogenerated": false,
"ratio": 3.52... |
"""2D Fourier mapping"""
import numpy as np
import scipy.interpolate as intp
def fourier_map_2d(uSin, angles, res, nm, lD=0, semi_coverage=False,
coords=None, count=None, max_count=None, verbose=0):
r"""2D Fourier mapping with the Fourier diffraction theorem
Two-dimensional diffraction tom... | {
"repo_name": "RI-imaging/ODTbrain",
"path": "odtbrain/_alg2d_fmp.py",
"copies": "2",
"size": "9369",
"license": "bsd-3-clause",
"hash": 4093693129342112000,
"line_mean": 34.6283524904,
"line_max": 76,
"alpha_frac": 0.6084525218,
"autogenerated": false,
"ratio": 3.2054463977938643,
"config_test... |
# 2d grid posterior approximation to N(x|mu,sigma^2) N(mu) Cauchy(sigma)
# https://www.ritchievink.com/blog/2019/06/10/bayesian-inference-how-we-are-able-to-chase-the-posterior/
import numpy as np
import matplotlib.pyplot as plt
from scipy import stats
figdir = "../figures"
import os
def save_fig(fname):
if figdi... | {
"repo_name": "probml/pyprobml",
"path": "scripts/posteriorGrid2d.py",
"copies": "1",
"size": "1566",
"license": "mit",
"hash": -2924953730165457400,
"line_mean": 26,
"line_max": 104,
"alpha_frac": 0.7056194125,
"autogenerated": false,
"ratio": 2.76678445229682,
"config_test": false,
"has_no_... |
"""2D histograms
"""
import pylab
import pandas as pd
import numpy as np
from .core import VizInput2D
__all__ = ["Hist2D"]
class Hist2D(VizInput2D):
"""2D histogram
.. plot::
:include-source:
:width: 80%
from numpy import random
from biokit.viz import hist2d
X =... | {
"repo_name": "biokit/biokit",
"path": "biokit/viz/hist2d.py",
"copies": "1",
"size": "3513",
"license": "bsd-2-clause",
"hash": 4153284619454772700,
"line_mean": 30.9363636364,
"line_max": 94,
"alpha_frac": 0.559920296,
"autogenerated": false,
"ratio": 3.6978947368421053,
"config_test": false,... |
"""2D plots of sound fields etc."""
import matplotlib as _mpl
import matplotlib.pyplot as _plt
from mpl_toolkits import axes_grid1 as _axes_grid1
import numpy as _np
from . import default as _default
from . import util as _util
def _register_cmap_clip(name, original_cmap, alpha):
"""Create a color map with "over... | {
"repo_name": "sfstoolbox/sfs-python",
"path": "sfs/plot2d.py",
"copies": "1",
"size": "16320",
"license": "mit",
"hash": -32249871491684236,
"line_mean": 33.8717948718,
"line_max": 79,
"alpha_frac": 0.5824754902,
"autogenerated": false,
"ratio": 3.4503171247357294,
"config_test": false,
"has... |
## 2. Drawing lines ##
import matplotlib.pyplot as plt
import numpy as np
x = [0, 1, 2, 3, 4, 5]
# Going by our formula, every y value at a position is the same as the x-value in the same position.
# We could write y = x, but let's write them all out to make this more clear.
y = [0, 1, 2, 3, 4, 5]
# As you can see, ... | {
"repo_name": "vipmunot/Data-Analysis-using-Python",
"path": "Probability Statistics Beginner/Linear regression-15.py",
"copies": "1",
"size": "4449",
"license": "mit",
"hash": -6005366155877097000,
"line_mean": 30.7857142857,
"line_max": 148,
"alpha_frac": 0.6970105642,
"autogenerated": false,
"... |
"""2D Refocusing of an HL60 cell
The data show a live HL60 cell imaged with quadriwave lateral shearing
interferometry (SID4Bio, Phasics S.A., France).
The diameter of the cell is about 20µm.
"""
import matplotlib.pylab as plt
import numpy as np
import unwrap
import nrefocus
from example_helper import load_cell
# l... | {
"repo_name": "RI-imaging/nrefocus",
"path": "examples/refocus_cell.py",
"copies": "2",
"size": "1999",
"license": "bsd-3-clause",
"hash": -6772581231595450000,
"line_mean": 27.9565217391,
"line_max": 70,
"alpha_frac": 0.6861861862,
"autogenerated": false,
"ratio": 2.6289473684210525,
"config_t... |
# 2D Semantic Segmentation
# License John Lambert
# Stanford University
from scipy.misc import imread, imresize
import numpy as np
#from '/Applications/MATLAB_R2016a.app/extern/engines/python/build/lib/matlab/engine'
import matlab.engine
import os.path
import time
import tensorflow as tf
import os, sys
import csv
i... | {
"repo_name": "johnwlambert/DendriticSpineSegmentationAndDetection",
"path": "2DFullyConvSegmentationConvNet_v4WeightedSigmoidCE.py",
"copies": "1",
"size": "15564",
"license": "mit",
"hash": -1183719267047980300,
"line_mean": 39.0128534704,
"line_max": 145,
"alpha_frac": 0.6786815729,
"autogenerat... |
"""2D slow integration"""
import numpy as np
def integrate_2d(uSin, angles, res, nm, lD=0, coords=None,
count=None, max_count=None, verbose=0):
r"""(slow) 2D reconstruction with the Fourier diffraction theorem
Two-dimensional diffraction tomography reconstruction
algorithm for scattering... | {
"repo_name": "paulmueller/ODTbrain",
"path": "odtbrain/_alg2d_int.py",
"copies": "2",
"size": "9866",
"license": "bsd-3-clause",
"hash": -4585641611240731000,
"line_mean": 34.9225092251,
"line_max": 77,
"alpha_frac": 0.5715459682,
"autogenerated": false,
"ratio": 3.140322580645161,
"config_tes... |
# 2D Vector
import math
class Vector(object):
@staticmethod
def add(v1, v2):
"""Adds two vectors and returns the product. """
return Vector(v1._x + v2._x, v1._y + v2._y)
@staticmethod
def sub(v1, v2):
"""Subtracts v2 from v1 and returns the product."""
return Vector(v... | {
"repo_name": "gregroper/Pycipia",
"path": "lwmath/Vector.py",
"copies": "1",
"size": "2920",
"license": "mit",
"hash": 3995369033671237000,
"line_mean": 26.2897196262,
"line_max": 77,
"alpha_frac": 0.4917808219,
"autogenerated": false,
"ratio": 3.5436893203883497,
"config_test": false,
"has_... |
# 2-electron VMC code for 2dim quantum dot with importance sampling
# No Coulomb interaction
# Using gaussian rng for new positions and Metropolis- Hastings
# Energy minimization using standard gradient descent
# Common imports
import os
# Where to save the figures and data files
PROJECT_ROOT_DIR = "Results"
FIGURE... | {
"repo_name": "CompPhysics/ComputationalPhysics2",
"path": "doc/src/MCsummary/src/mpqdot.py",
"copies": "1",
"size": "5905",
"license": "cc0-1.0",
"hash": -2267066061847252700,
"line_mean": 31.8055555556,
"line_max": 92,
"alpha_frac": 0.6758679086,
"autogenerated": false,
"ratio": 3.2250136537411... |
# 2-electron VMC code for 2dim quantum dot with importance sampling
# Using gaussian rng for new positions and Metropolis- Hastings
# Added energy minimization
# Common imports
from math import exp, sqrt
from random import random, seed, normalvariate
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits... | {
"repo_name": "CompPhysics/ComputationalPhysics2",
"path": "doc/src/MCsummary/src/qdoteminim.py",
"copies": "2",
"size": "5916",
"license": "cc0-1.0",
"hash": 5398027345953398000,
"line_mean": 35.2944785276,
"line_max": 138,
"alpha_frac": 0.6512846518,
"autogenerated": false,
"ratio": 3.007625826... |
# 2-electron VMC code for 2dim quantum dot with importance sampling
# Using gaussian rng for new positions and Metropolis- Hastings
# Added energy minimization
from math import exp, sqrt
from random import random, seed, normalvariate
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import A... | {
"repo_name": "CompPhysics/ComputationalPhysics2",
"path": "doc/Programs/BoltzmannMachines/VMC/python/qdotBroyden.py",
"copies": "2",
"size": "8051",
"license": "cc0-1.0",
"hash": -5736781454099594000,
"line_mean": 34.6238938053,
"line_max": 105,
"alpha_frac": 0.6337100981,
"autogenerated": false,
... |
# 2-electron VMC code for 2dim quantum dot with importance sampling
# Using gaussian rng for new positions and Metropolis- Hastings
# No energy minimization
from math import exp, sqrt
from random import random, seed, normalvariate
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes... | {
"repo_name": "CompPhysics/ComputationalPhysics2",
"path": "doc/Programs/ConjugateGradient/python/qdotnint.py",
"copies": "1",
"size": "4670",
"license": "cc0-1.0",
"hash": 8638217723136608000,
"line_mean": 34.3787878788,
"line_max": 92,
"alpha_frac": 0.6582441113,
"autogenerated": false,
"ratio"... |
# 2-electron VMC for quantum dot system in two dimensions
# Brute force Metropolis, no importance sampling and no energy minimization
from math import exp, sqrt
from random import random, seed
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
from matplotlib import cm
from matpl... | {
"repo_name": "CompPhysics/ComputationalPhysics2",
"path": "doc/Programs/ConjugateGradient/python/qdotmetropolis.py",
"copies": "1",
"size": "4473",
"license": "cc0-1.0",
"hash": 7610836137299340000,
"line_mean": 35.3658536585,
"line_max": 105,
"alpha_frac": 0.6295551084,
"autogenerated": false,
... |
## 2. Enumerate ##
ships = ["Andrea Doria", "Titanic", "Lusitania"]
cars = ["Ford Edsel", "Ford Pinto", "Yugo"]
for i,item in enumerate(ships):
print(item)
print(cars[i])
## 3. Adding Columns ##
things = [["apple", "monkey"], ["orange", "dog"], ["banana", "cat"]]
trees = ["cedar", "maple", "fig"]
for i, item... | {
"repo_name": "vipmunot/Data-Analysis-using-Python",
"path": "Python Programming Intermediate/List Comprehensions-16.py",
"copies": "1",
"size": "2151",
"license": "mit",
"hash": 5531344968793942000,
"line_mean": 24.9277108434,
"line_max": 68,
"alpha_frac": 0.6052998605,
"autogenerated": false,
"... |
## 2. Extract Line Numbers ##
raw_hamlet = sc.textFile("hamlet.txt")
split_hamlet = raw_hamlet.map(lambda line: line.split('\t'))
split_hamlet.take(5)
def format_id(x):
id = x[0].split('@')[1]
results = list()
results.append(id)
if len(x) > 1:
for y in x[1:]:
results.append(y)
r... | {
"repo_name": "vipmunot/Data-Analysis-using-Python",
"path": "pySpark/Challenge_ Transforming Hamlet into a Data Set-124.py",
"copies": "1",
"size": "1025",
"license": "mit",
"hash": -3681280010474772500,
"line_mean": 24.65,
"line_max": 75,
"alpha_frac": 0.5980487805,
"autogenerated": false,
"rat... |
## 2. Finding correlations ##
correlations = combined.corr()
correlations = correlations["sat_score"]
print(correlations)
## 3. Plotting enrollment ##
import matplotlib.pyplot as plt
combined.plot.scatter(x='total_enrollment', y='sat_score')
plt.show()
## 4. Exploring schools with low SAT scores and enrollment ##
... | {
"repo_name": "vipmunot/Data-Analysis-using-Python",
"path": "Data Exploration/Data Cleaning Walkthrough_ Analyzing And Visualizing The Data-210.py",
"copies": "1",
"size": "2405",
"license": "mit",
"hash": 6963367545178510000,
"line_mean": 24.5957446809,
"line_max": 103,
"alpha_frac": 0.7097713098,
... |
# 2. fn/names_text
# Parameters: text (required), engine (optional)
import sys, os, unittest, json, codecs
sys.path.append('./')
sys.path.append('../')
import webapp
service = webapp.get_service(5004, 'fn/names_text')
the_sample = None
def get_sample():
global the_sample
if the_sample == None:
with... | {
"repo_name": "jar398/tryphy",
"path": "tests/test_fn_names_text.py",
"copies": "1",
"size": "3503",
"license": "bsd-2-clause",
"hash": -2101260319275050500,
"line_mean": 41.2048192771,
"line_max": 432,
"alpha_frac": 0.6488723951,
"autogenerated": false,
"ratio": 3.4444444444444446,
"config_tes... |
# 2 Gold Stars
# One way search engines rank pages
# is to count the number of times a
# searcher clicks on a returned link.
# This indicates that the person doing
# the query thought this was a useful
# link for the query, so it should be
# higher in the rankings next time.
# (In Unit 6, we will look at a different
... | {
"repo_name": "W0mpRat/IntroToComputerScience",
"path": "Lesson4/CountingClicks.py",
"copies": "1",
"size": "3668",
"license": "unlicense",
"hash": 5053235345235291000,
"line_mean": 27.6640625,
"line_max": 79,
"alpha_frac": 0.6199563795,
"autogenerated": false,
"ratio": 3.343664539653601,
"conf... |
## 2. Implementing an Algorithm ##
# When the algorithm finds Kobe in the data set, store his position in Kobe_position
kobe_position = ""
# Find Kobe in the data set
for item in nba:
if item[0]== 'Kobe Bryant':
kobe_position = item[1]
## 4. Linear Search with Modular Code ##
# player_age returns the ag... | {
"repo_name": "vipmunot/Data-Analysis-using-Python",
"path": "Data Structures & Algorithms/Algorithms-92.py",
"copies": "1",
"size": "1702",
"license": "mit",
"hash": -4694796253325890000,
"line_mean": 23.3285714286,
"line_max": 84,
"alpha_frac": 0.6498237368,
"autogenerated": false,
"ratio": 3.1... |
""" 2-input XOR example using Izhikevich's spiking neuron model. """
from __future__ import print_function
import multiprocessing
import os
from matplotlib import patches
from matplotlib import pylab as plt
import visualize
import neat
# Network inputs and expected outputs.
xor_inputs = ((0, 0), (0, 1), (1, 0), (1... | {
"repo_name": "CodeReclaimers/neat-python",
"path": "examples/xor/evolve-spiking.py",
"copies": "1",
"size": "5782",
"license": "bsd-3-clause",
"hash": -1212478639902887200,
"line_mean": 35.3647798742,
"line_max": 100,
"alpha_frac": 0.6240055344,
"autogenerated": false,
"ratio": 3.349942062572422... |
""" 2-input XOR example using Izhikevich's spiking neuron model. """
from __future__ import print_function
import os
from matplotlib import pylab as plt
from matplotlib import patches
import neat
import visualize
# Network inputs and expected outputs.
xor_inputs = ((0, 0), (0, 1), (1, 0), (1, 1))
xor_outputs = (0, 1... | {
"repo_name": "drallensmith/neat-python",
"path": "examples/xor/evolve-spiking.py",
"copies": "1",
"size": "5804",
"license": "bsd-3-clause",
"hash": -8673809357334075000,
"line_mean": 35.5031446541,
"line_max": 100,
"alpha_frac": 0.6200895934,
"autogenerated": false,
"ratio": 3.3375503162737203,... |
## 2. Introduction to the Data ##
import csv
nfl_suspensions = list(csv.reader(open('nfl_suspensions_data.csv','r')))[1:]
#nfl_suspensions = [item[1:] for item in nfl_suspensions]
years = {}
for item in nfl_suspensions:
if item[5] in years:
years[item[5]] +=1
else:
years[item[5]] = 1
print(year... | {
"repo_name": "vipmunot/Data-Analysis-using-Python",
"path": "Python Programming Intermediate/Challenge_ Modules, Classes, Error Handling, and List Comprehensions-186.py",
"copies": "1",
"size": "1273",
"license": "mit",
"hash": 2018127548106726100,
"line_mean": 23.9803921569,
"line_max": 76,
"alpha_... |
## 2. Introduction to the Data ##
import pandas as pd
all_ages = pd.read_csv('all-ages.csv')
recent_grads = pd.read_csv('recent-grads.csv')
print(all_ages.head())
print(recent_grads.head())
## 3. Summarizing Major Categories ##
# Unique values in Major_category column.
print(all_ages['Major_category'].unique())
aa_... | {
"repo_name": "vipmunot/Data-Analysis-using-Python",
"path": "Data Analysis with Pandas Intermediate/Challenge_ Summarizing Data-112.py",
"copies": "1",
"size": "1259",
"license": "mit",
"hash": 3571526071365128000,
"line_mean": 29.7317073171,
"line_max": 95,
"alpha_frac": 0.6783161239,
"autogenera... |
## 2. Introduction to the data ##
import pandas as pd
import matplotlib.pyplot as plt
admissions = pd.read_csv('admissions.csv')
plt.scatter(admissions['gpa'],admissions['admit'])
plt.show()
## 4. Logit function ##
import numpy as np
# Logit Function
def logit(x):
# np.exp(x) raises x to the exponential power, ... | {
"repo_name": "vipmunot/Data-Analysis-using-Python",
"path": "Machine learning Beginner/Logistic regression-56.py",
"copies": "1",
"size": "1444",
"license": "mit",
"hash": 3952839229870808000,
"line_mean": 27.9,
"line_max": 71,
"alpha_frac": 0.7174515235,
"autogenerated": false,
"ratio": 3.15973... |
## 2. Introduction To The Data ##
import pandas as pd
import matplotlib.pyplot as plt
women_degrees = pd.read_csv('percent-bachelors-degrees-women-usa.csv')
plt.plot(women_degrees['Year'],women_degrees['Biology'])
plt.show()
## 3. Visualizing The Gender Gap ##
plt.plot(women_degrees['Year'],women_degrees['Biology']... | {
"repo_name": "vipmunot/Data-Analysis-using-Python",
"path": "Storytelling Data Visualization/Improving Plot Aesthetics-220.py",
"copies": "1",
"size": "2180",
"license": "mit",
"hash": 4422019673359032000,
"line_mean": 35.9661016949,
"line_max": 93,
"alpha_frac": 0.6811926606,
"autogenerated": fal... |
## 2. Introduction to the data ##
import pandas as pd
reviews = pd.read_csv('fandango_scores.csv')
cols = ['FILM', 'RT_user_norm', 'Metacritic_user_nom', 'IMDB_norm', 'Fandango_Ratingvalue', 'Fandango_Stars']
norm_reviews = reviews[cols]
print(norm_reviews[:1])
## 4. Creating Bars ##
import matplotlib.pyplot as plt
... | {
"repo_name": "vipmunot/Data-Analysis-using-Python",
"path": "Exploratory Data Visualization/Bar Plots And Scatter Plots-217.py",
"copies": "1",
"size": "3043",
"license": "mit",
"hash": 1026446975846338700,
"line_mean": 29.44,
"line_max": 109,
"alpha_frac": 0.7183700296,
"autogenerated": false,
... |
## 2. Lists of lists ##
import csv
world_alcohol = list(csv.reader(open('world_alcohol.csv','r')))
years= [int(item[0]) for item in world_alcohol[1:]]
total = sum(years)
avg_year = total/len(years)
## 4. Using NumPy ##
import numpy
world_alcohol = numpy.genfromtxt("world_alcohol.csv", delimiter=",")
print(type(world... | {
"repo_name": "vipmunot/Data-Analysis-using-Python",
"path": "Data Analysis with Pandas Intermediate/Getting started with NumPy-6.py",
"copies": "1",
"size": "1281",
"license": "mit",
"hash": 8424053905647226000,
"line_mean": 22.7407407407,
"line_max": 99,
"alpha_frac": 0.669008587,
"autogenerated"... |
## 2. Looking at the data ##
import pandas as pd
submissions = pd.read_csv("sel_hn_stories.csv")
submissions.columns = ["submission_time", "upvotes", "url", "headline"]
submissions = submissions.dropna()
## 3. Tokenization ##
tokenized_headlines = []
for value in submissions["headline"]:
tokenized_headlines.app... | {
"repo_name": "vipmunot/Data-Analysis-using-Python",
"path": "Natural Language Processing/Introduction to natural language processing-158.py",
"copies": "1",
"size": "1972",
"license": "mit",
"hash": -7699341085713866000,
"line_mean": 25.6351351351,
"line_max": 114,
"alpha_frac": 0.6487309645,
"aut... |
## 2. Looking at the data ##
# We can use the pandas library in python to read in the csv file.
# This creates a pandas dataframe and assigns it to the titanic variable.
titanic = pandas.read_csv("titanic_train.csv")
# Print the first 5 rows of the dataframe.
print(titanic.head(5))
print(titanic.describe())
## 3. Mi... | {
"repo_name": "vipmunot/Data-Analysis-using-Python",
"path": "Kaggle Competitions/Getting started with Kaggle-73.py",
"copies": "1",
"size": "4368",
"license": "mit",
"hash": -5394495463459755000,
"line_mean": 37.3245614035,
"line_max": 118,
"alpha_frac": 0.7184065934,
"autogenerated": false,
"ra... |
## 2. Mutability ##
class Counter():
def __init__(self):
self.count = 0
def increment(self):
self.count += 1
def get_count(self):
return self.count
def count_up_100000(counter):
for i in range(100000):
counter.increment()
class Counter():
def __init__(self):
... | {
"repo_name": "vipmunot/Data-Analysis-using-Python",
"path": "Python Programming Advanced/Parallel Processing-171.py",
"copies": "1",
"size": "4804",
"license": "mit",
"hash": 894002071476223900,
"line_mean": 21.6650943396,
"line_max": 81,
"alpha_frac": 0.664029975,
"autogenerated": false,
"ratio... |
# 2
# 5 3
# 1 2 4 5 6
# 5 3
# 1 2 4 5 7
n = 5
K = 3
dp = [[0 for i in xrange(2**n)] for k in xrange(K+1)]
a = [1,2,4,5,6]
# a = [1,2,4,5,7]
x = int(sum(a) / K)
dp[0][0] = 1
for k in xrange(K):
for bitmask in xrange(2**n):
if not dp[k][bitmask]:
continue
s = 0
for i in xrange(... | {
"repo_name": "parinck/cook",
"path": "codechef/sanskar.py",
"copies": "2",
"size": "1181",
"license": "mit",
"hash": -914744041901318400,
"line_mean": 21.3018867925,
"line_max": 66,
"alpha_frac": 0.4580863675,
"autogenerated": false,
"ratio": 2.8119047619047617,
"config_test": false,
"has_no... |
"""2nd database upgrade
Revision ID: d440fe2187fa
Revises: None
Create Date: 2016-06-05 21:55:18.797000
"""
# revision identifiers, used by Alembic.
revision = 'd440fe2187fa'
down_revision = None
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import mysql
def upgrade():
### commands au... | {
"repo_name": "zlasd/flaskr_exercise",
"path": "migrations/versions/d440fe2187fa_2nd_database_upgrade.py",
"copies": "1",
"size": "1331",
"license": "mit",
"hash": 5903061786855625000,
"line_mean": 35.9722222222,
"line_max": 120,
"alpha_frac": 0.6784372652,
"autogenerated": false,
"ratio": 3.2945... |
# 2nd-order accurate finite-volume implementation of linear advection with
# piecewise linear slope reconstruction
#
# We are solving a_t + u a_x = 0
#
# M. Zingale (2013-03-24)
import numpy
import pylab
import math
class ccFVgrid:
def __init__(self, nx, ng, xmin=0.0, xmax=1.0):
self.xmin = xmin
... | {
"repo_name": "bt3gl/Numerical-Methods-for-Physics",
"path": "others/advection/fv_advection.py",
"copies": "1",
"size": "5211",
"license": "apache-2.0",
"hash": -6059247351424842000,
"line_mean": 21.364806867,
"line_max": 78,
"alpha_frac": 0.5248512761,
"autogenerated": false,
"ratio": 3.00519031... |
# 2nd-order accurate finite-volume implementation of the inviscid Burger's equation
# with piecewise linear slope reconstruction
#
# We are solving u_t + u u_x = 0 with outflow boundary conditions
#
# M. Zingale (2013-03-26)
import numpy
import pylab
import math
import sys
class ccFVgrid:
def __init__(self, nx,... | {
"repo_name": "bt3gl/Numerical-Methods-for-Physics",
"path": "others/advection/fv_burgers.py",
"copies": "1",
"size": "7293",
"license": "apache-2.0",
"hash": -1460346586849891600,
"line_mean": 21.8620689655,
"line_max": 83,
"alpha_frac": 0.4768956534,
"autogenerated": false,
"ratio": 2.911377245... |
# 2nd-order accurate finite-volume implementation of the inviscid Burger's
# equation with piecewise linear slope reconstruction
#
# We are solving u_t + u u_x = 0 with outflow boundary conditions
#
# M. Zingale (2013-03-26)
import numpy as np
import matplotlib.pyplot as plt
import matplotlib as mpl
import sys
mpl.rc... | {
"repo_name": "zingale/hydro_examples",
"path": "burgers/burgers.py",
"copies": "1",
"size": "7466",
"license": "bsd-3-clause",
"hash": -4261778056769246000,
"line_mean": 23.803986711,
"line_max": 86,
"alpha_frac": 0.4902223413,
"autogenerated": false,
"ratio": 3.022672064777328,
"config_test":... |
# 2nd-order accurate finite-volume implementation of the inviscid Burger's
# equation with piecewise linear slope reconstruction
#
# We are solving u_t + u u_x = 0 with outflow boundary conditions
#
# M. Zingale (2013-03-26)
import numpy
import pylab
import math
import sys
class Grid1d:
def __init__(self, nx, ... | {
"repo_name": "JeffDestroyerOfWorlds/hydro_examples",
"path": "burgers/burgers.py",
"copies": "1",
"size": "6543",
"license": "bsd-3-clause",
"hash": 6555722672691561000,
"line_mean": 23.1439114391,
"line_max": 79,
"alpha_frac": 0.5052728106,
"autogenerated": false,
"ratio": 2.940674157303371,
... |
import numpy as np
from sympy import symbols, sin, cos, lambdify
from shenfun import *
import matplotlib.pyplot as plt
from matplotlib.ticker import NullFormatter
# pylint: disable=multiple-statements
from mpltools import annotation
pa = {'fill': False, 'edgecolor': 'black'}
ta = {'fontsize': 10}
pex = lambda *args... | {
"repo_name": "spectralDNS/shenfun",
"path": "demo/NavierStokesPC.py",
"copies": "1",
"size": "7513",
"license": "bsd-2-clause",
"hash": 6916785474719700000,
"line_mean": 32.0969162996,
"line_max": 84,
"alpha_frac": 0.5659523493,
"autogenerated": false,
"ratio": 2.5313342318059298,
"config_test... |
import numpy as np
from sympy import symbols, sin, cos, lambdify
from shenfun import *
import matplotlib.pyplot as plt
from matplotlib.ticker import NullFormatter, ScalarFormatter
from mpltools import annotation
pa = {'fill': False, 'edgecolor': 'black'}
ta = {'fontsize': 10}
pex = lambda *args: print(*args) + exit(... | {
"repo_name": "spectralDNS/shenfun",
"path": "demo/StokesPC.py",
"copies": "1",
"size": "6793",
"license": "bsd-2-clause",
"hash": -5098144695905062000,
"line_mean": 31.6586538462,
"line_max": 84,
"alpha_frac": 0.5644045341,
"autogenerated": false,
"ratio": 2.57701062215478,
"config_test": fals... |
"""2nd pass at adding IRONMAN 3 digit identifiers
Revision ID: 4ea2b79957f3
Revises: d561999e9b42
Create Date: 2019-04-30 12:17:03.382443
"""
import re
from alembic import op
from sqlalchemy.orm.session import Session
from portal.models.identifier import Identifier
from portal.models.organization import Organizatio... | {
"repo_name": "uwcirg/true_nth_usa_portal",
"path": "portal/migrations/versions/4ea2b79957f3_.py",
"copies": "1",
"size": "4167",
"license": "bsd-3-clause",
"hash": -1318155700847623400,
"line_mean": 36.5405405405,
"line_max": 76,
"alpha_frac": 0.5987520998,
"autogenerated": false,
"ratio": 4.026... |
# 2nd step of the process - constructing the index
import os, sys, math;
import pickle, glob, re;
from operator import itemgetter;
from os.path import join;
# read the tf and idf objects
# tff contains the tf dictionaries for each file as index
tfpck=open("tfpickle.pkl","rb");
tff=pickle.load(tfpck);
tfpck... | {
"repo_name": "gnokem/blog-code",
"path": "tfidf_summarizer.py",
"copies": "1",
"size": "2109",
"license": "mit",
"hash": -8556239723070361000,
"line_mean": 26.12,
"line_max": 86,
"alpha_frac": 0.6448553817,
"autogenerated": false,
"ratio": 2.81951871657754,
"config_test": false,
"has_no_keyw... |
"""2nd update that adds an index on the user_id column
Revision ID: 3414dfab0e91
Revises: 52feb4cd3e65
Create Date: 2015-10-09 12:16:31.095629
"""
# revision identifiers, used by Alembic.
revision = '3414dfab0e91'
down_revision = '52feb4cd3e65'
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects... | {
"repo_name": "Rdbaker/GameCenter",
"path": "migrations/versions/3414dfab0e91_.py",
"copies": "2",
"size": "1110",
"license": "mit",
"hash": 4268377765724918300,
"line_mean": 31.6470588235,
"line_max": 83,
"alpha_frac": 0.6621621622,
"autogenerated": false,
"ratio": 3.3944954128440368,
"config_... |
# 2.
# Используя расщепление матрицы Стилтьеса, отвечающее её неполной факторизации по методу ILU(k),
# реализовать стационарный итерационный процесс и исследовать скорость его сходимости
#
# стр. 65 - Основные стационарные итерационные процессы
# стр. 75 - ускорение сходимости стационарных итерационных процессов
#
... | {
"repo_name": "maxmalysh/congenial-octo-adventure",
"path": "mod2/task2.py",
"copies": "1",
"size": "3649",
"license": "unlicense",
"hash": 5055167547906019000,
"line_mean": 26.9237288136,
"line_max": 97,
"alpha_frac": 0.5154826958,
"autogenerated": false,
"ratio": 2.2122229684351913,
"config_t... |
#2 okay lets do this
import sys
sys.path.append('../.')
import pandas as pd
import numpy as np
import itertools as it
import path_planner as plan
pathName = '../../data-se3-path-planner/cherylData/'
pathName1 = '../../data-se3-path-planner/yearData/batch2019/'
months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', ... | {
"repo_name": "fsbr/se3-path-planner",
"path": "modularPlanner/cuspAnalyze.py",
"copies": "2",
"size": "5214",
"license": "mit",
"hash": 6572577738920635000,
"line_mean": 34.9586206897,
"line_max": 110,
"alpha_frac": 0.6058688147,
"autogenerated": false,
"ratio": 3.0598591549295775,
"config_tes... |
## 2. Opening Files ##
a = open("test.txt", "r")
print(a)
f = open("crime_rates.csv", "r")
## 3. Reading In Files ##
f = open("crime_rates.csv", "r")
data = f.read()
## 4. Splitting ##
# We can split a string into a list.
sample = "john,plastic,joe"
split_list = sample.split(",")
print(split_list)
# Here's anothe... | {
"repo_name": "vipmunot/Data-Analysis-using-Python",
"path": "Python Programming Beginner/Files and Loops-2.py",
"copies": "1",
"size": "1881",
"license": "mit",
"hash": -4257560896612518000,
"line_mean": 20.8837209302,
"line_max": 86,
"alpha_frac": 0.6422115896,
"autogenerated": false,
"ratio": ... |
''' 2-orbits_computed.py
=========================
AIM: Verify which orbits were actually computed by the pipeline
INPUT: files: - all flux_*.dat files in <orbit_id>_flux/
variables: see section PARAMETERS (below)
OUTPUT: in <orbit_id>_misc/ : one file 'orbits.dat' containing the list
CMD: python 2-orbits_computed... | {
"repo_name": "kuntzer/SALSA-public",
"path": "2_orbits_computed.py",
"copies": "1",
"size": "2376",
"license": "bsd-3-clause",
"hash": 3813659845101292000,
"line_mean": 25.1098901099,
"line_max": 82,
"alpha_frac": 0.5913299663,
"autogenerated": false,
"ratio": 3.147019867549669,
"config_test":... |
## 2. Organizing our code ##
# Define the Trial class here
class Trial(object):
def __init__(self, datarow):
self.efficiency = float(datarow[0])
self.individual = int(datarow[1])
self.chopstick_length = int(datarow[2])
first_trial = Trial(chopsticks[0])
## 3. The Chopstick class ##
class ... | {
"repo_name": "vipmunot/Data-Analysis-using-Python",
"path": "Python Programming Advanced/Exception handling-110.py",
"copies": "1",
"size": "7474",
"license": "mit",
"hash": -7034552558635030000,
"line_mean": 30.0165975104,
"line_max": 102,
"alpha_frac": 0.5663633931,
"autogenerated": false,
"ra... |
## 2. Our dataset ##
import pandas
# Set index_col to False to avoid pandas thinking that the first column is row indexes (it's age).
income = pandas.read_csv("income.csv", index_col=False)
print(income.head(5))
## 3. Converting categorical variables ##
# Convert a single column from text categories into numbers.
c... | {
"repo_name": "vipmunot/Data-Analysis-using-Python",
"path": "Decision Trees/Introduction to Decision Trees-137.py",
"copies": "1",
"size": "3940",
"license": "mit",
"hash": -6466989242877481000,
"line_mean": 34.8272727273,
"line_max": 211,
"alpha_frac": 0.6824873096,
"autogenerated": false,
"rat... |
"""2.Phase"""
from sympy import *
init_printing()
z, x1, x2, x3, x4, x5, x6, x7 = symbols('z, x1, x2, x3, x4, x5, x6, x7')
B = [x1, x2, x4, x6, x7]
N = [x3, x5]
rows = [Eq(x4, 6 + 3 * x5 - 1 * x3),
Eq(x1, 2 - x5 + 1 * x3),
Eq(x2, 8 + 2 * x5 - 1 * x3),
Eq(x6, 22 - 5 * x5 + 1 * x3),... | {
"repo_name": "mazenbesher/simplex",
"path": "sympy_version/specific/blatt4_aufgabe2_iii.py",
"copies": "1",
"size": "2017",
"license": "mit",
"hash": -6708402545066076000,
"line_mean": 30.0307692308,
"line_max": 85,
"alpha_frac": 0.5205751116,
"autogenerated": false,
"ratio": 2.7706043956043955,... |
## 2. Point Guards ##
# Enter code here.
point_guards = nba[nba["pos"] == "PG"]
## 3. Points Per Game ##
point_guards['ppg'] = point_guards['pts'] / point_guards['g']
# Sanity check, make sure ppg = pts/g
point_guards[['pts', 'g', 'ppg']].head(5)
## 4. Assist Turnover Ratio ##
point_guards = point_guards[point_gu... | {
"repo_name": "vipmunot/Data-Analysis-using-Python",
"path": "Machine learning Intermediate/K-means clustering-95.py",
"copies": "1",
"size": "4063",
"license": "mit",
"hash": 4968914129924903000,
"line_mean": 28.2374100719,
"line_max": 90,
"alpha_frac": 0.6729017967,
"autogenerated": false,
"rat... |
## 2. Probability of renting bikes ##
import pandas
bikes = pandas.read_csv("bike_rental_day.csv")
# Find the number of days the bikes rented exceeded the threshold.
days_over_threshold = bikes[bikes["cnt"] > 2000].shape[0]
# Find the total number of days we have data for.
total_days = bikes.shape[0]
# Get the proba... | {
"repo_name": "vipmunot/Data-Analysis-using-Python",
"path": "Probability Statistics Intermediate/Calculating probabilities-134.py",
"copies": "1",
"size": "2066",
"license": "mit",
"hash": 2333814900466093600,
"line_mean": 28.9565217391,
"line_max": 88,
"alpha_frac": 0.701839303,
"autogenerated": ... |
2#-------------------------------------------------------------------------------
# Name: module1
# Purpose:
#
# Author: Administrator
#
# Created: 08/10/2011
# Copyright: (c) Administrator 2011
# Licence: <your licence>
#-------------------------------------------------------------------... | {
"repo_name": "hemmerling/codingdojo",
"path": "src/game_of_life/python_coderetreat_berlin_2014-09/python_legacycrberlin02/gol02.py",
"copies": "1",
"size": "1049",
"license": "apache-2.0",
"hash": 3356558385341113300,
"line_mean": 24.275,
"line_max": 81,
"alpha_frac": 0.4671115348,
"autogenerated"... |
## 2. Sets ##
#legislators = list(csv.reader(open('legislators.csv','r')))
gender = []
for item in legislators:
gender.append(item[3])
gender = set(gender)
print(gender)
## 3. Exploring the Dataset ##
party = []
for item in legislators:
party.append(item[6])
party = set(party)
print(party)
print(legislators)... | {
"repo_name": "vipmunot/Data-Analysis-using-Python",
"path": "Python Programming Intermediate/Error Handling-7.py",
"copies": "1",
"size": "1303",
"license": "mit",
"hash": 4636334197409308000,
"line_mean": 16.8630136986,
"line_max": 60,
"alpha_frac": 0.6162701458,
"autogenerated": false,
"ratio"... |
## 2. Systems of equations as matrices ##
import numpy as np
# Set the dtype to float to do float math with the numbers.
matrix = np.asarray([
[2, 1, 25],
[3, 2, 40]
], dtype=np.float32)
matrix[0] = matrix[0] * 2
matrix[0] = matrix[0] - matrix[1]
matrix[1] = matrix[1] - (matrix[0] * 3)
matrix[1] /= 2
print(... | {
"repo_name": "vipmunot/Data-Analysis-using-Python",
"path": "Linear Algebra/Solving systems of equations with matrices-55.py",
"copies": "1",
"size": "2582",
"license": "mit",
"hash": 6122938107126201000,
"line_mean": 22.0625,
"line_max": 99,
"alpha_frac": 0.5766847405,
"autogenerated": false,
"... |
# 2. telnetlib
#
# a. Write a script that connects using telnet to the pynet-rtr1 router.
# Execute the 'show ip int brief' command on the router and return the output.
#
# Try to do this on your own (i.e. do not copy what I did previously). You should be able to do this by using the following items:
#
# telnet... | {
"repo_name": "linkdebian/pynet_course",
"path": "class2/exercise2.py",
"copies": "1",
"size": "1143",
"license": "apache-2.0",
"hash": -7075083346293237000,
"line_mean": 24.4,
"line_max": 130,
"alpha_frac": 0.719160105,
"autogenerated": false,
"ratio": 2.901015228426396,
"config_test": false,
... |
## 2. The Basics of Binary ##
# Let's say b is a binary number. In python, we have to store binary numbers as strings.
# If we try to enter it directly as b = 10, Python will assume it's a base 10 integer.
b = "10"
# Now, we can convert b from a string to a binary number with the int function. We'll need to set the ... | {
"repo_name": "vipmunot/Data-Analysis-using-Python",
"path": "Data Structures & Algorithms/Memory and Unicode-13.py",
"copies": "1",
"size": "11671",
"license": "mit",
"hash": 6067693329024267000,
"line_mean": 35.1708074534,
"line_max": 289,
"alpha_frac": 0.7148377125,
"autogenerated": false,
"ra... |
## 2. The dataset ##
import pandas as pd
votes = pd.read_csv('114_congress.csv')
## 3. Exploring the data ##
print(votes['party'].value_counts())
print(votes.mean())
## 4. Distance between Senators ##
from sklearn.metrics.pairwise import euclidean_distances
print(euclidean_distances(votes.iloc[0,3:].reshape(1, -1... | {
"repo_name": "vipmunot/Data-Analysis-using-Python",
"path": "Machine learning Beginner/Clustering basics-59.py",
"copies": "1",
"size": "1230",
"license": "mit",
"hash": 3761524056747814400,
"line_mean": 25.7608695652,
"line_max": 96,
"alpha_frac": 0.7016260163,
"autogenerated": false,
"ratio": ... |
## 2. The mean as the center ##
# Make a list of values
values = [2, 4, 5, -1, 0, 10, 8, 9]
# Compute the mean of the values
values_mean = sum(values) / len(values)
# Find the difference between each of the values and the mean by subtracting the mean from each value.
differences = [i - values_mean for i in values]
# T... | {
"repo_name": "vipmunot/Data-Analysis-using-Python",
"path": "Probability Statistics Beginner/Standard deviation and correlation-14.py",
"copies": "1",
"size": "10049",
"license": "mit",
"hash": 8537288113958745000,
"line_mean": 38.880952381,
"line_max": 415,
"alpha_frac": 0.6880286596,
"autogenera... |
# 2. 删除操作
class Animal:
name = "动物"
age = 10
# a1 = Animal()
# print(Animal.name)
# # 动物
# del a1.__class__.name
# print(Animal.__dict__)
# {'__module__': '__main__',
# 'age': 10, '__dict__': <attribute '__dict__' of 'Animal' objects>,
# '__weakref__': <attribute '__weakref__' of 'Animal' objects>,
# '__doc__'... | {
"repo_name": "z727354123/pyCharmTest",
"path": "2018-01/01_Jan/14/02-ClassAttribute.py",
"copies": "1",
"size": "1623",
"license": "apache-2.0",
"hash": 5399735191346132000,
"line_mean": 20.2328767123,
"line_max": 68,
"alpha_frac": 0.5661717237,
"autogenerated": false,
"ratio": 2.498387096774193... |
## 2. Using decision trees with scikit-learn ##
from sklearn.tree import DecisionTreeClassifier
# A list of columns to train with.
# All columns have been converted to numeric.
columns = ["age", "workclass", "education_num", "marital_status", "occupation", "relationship", "race", "sex", "hours_per_week", "native_coun... | {
"repo_name": "vipmunot/Data-Analysis-using-Python",
"path": "Decision Trees/Applying decision trees-143.py",
"copies": "1",
"size": "3748",
"license": "mit",
"hash": -529862598104107200,
"line_mean": 32.7657657658,
"line_max": 155,
"alpha_frac": 0.7395944504,
"autogenerated": false,
"ratio": 3.2... |
## 2. Web Page Structure ##
# Write your code here.
response = requests.get("http://dataquestio.github.io/web-scraping-pages/simple.html")
content = response.content
## 3. Retrieving Elements from a Page ##
from bs4 import BeautifulSoup
# Initialize the parser, and pass in the content we grabbed earlier.
parser = B... | {
"repo_name": "vipmunot/Data-Analysis-using-Python",
"path": "Apis and Scraping/Web Scraping-119.py",
"copies": "1",
"size": "3394",
"license": "mit",
"hash": 3204754187570022000,
"line_mean": 34.3645833333,
"line_max": 107,
"alpha_frac": 0.7386564526,
"autogenerated": false,
"ratio": 3.241642788... |
# 30.04.2009
#!
#! Linear Elasticity
#! =================
#$ \centerline{Example input file, \today}
#! This file models a cylinder that is fixed at one end while the
#! second end has a specified displacement of 0.01 in the x direction
#! (this boundary condition is named Displaced). There is also a specified
#! disp... | {
"repo_name": "olivierverdier/sfepy",
"path": "examples/linear_elasticity/linear_elastic.py",
"copies": "1",
"size": "3615",
"license": "bsd-3-clause",
"hash": 3724869877416006700,
"line_mean": 33.4285714286,
"line_max": 79,
"alpha_frac": 0.5587828492,
"autogenerated": false,
"ratio": 3.219056099... |
# 30.05.2007, c
# last revision: 25.02.2008
from __future__ import absolute_import
from sfepy import data_dir
import six
filename_mesh = data_dir + '/meshes/2d/square_unit_tri.mesh'
material_1 = {
'name' : 'coef',
'values' : {
'val' : 1.0,
},
}
material_2 = {
'name' : 'm',
'values' : {
... | {
"repo_name": "lokik/sfepy",
"path": "tests/test_laplace_unit_square.py",
"copies": "3",
"size": "5870",
"license": "bsd-3-clause",
"hash": -1831525260669356800,
"line_mean": 25.4414414414,
"line_max": 81,
"alpha_frac": 0.5052810903,
"autogenerated": false,
"ratio": 3.0652741514360313,
"config_... |
# 30.05.2007, c
# last revision: 25.02.2008
from sfepy import data_dir
filename_mesh = data_dir + '/meshes/2d/square_unit_tri.mesh'
material_1 = {
'name' : 'coef',
'values' : {
'val' : 1.0,
},
}
material_2 = {
'name' : 'm',
'values' : {
'K' : [[1.0, 0.0], [0.0, 1.0]],
},
}
fie... | {
"repo_name": "olivierverdier/sfepy",
"path": "tests/test_laplace_unit_square.py",
"copies": "1",
"size": "6037",
"license": "bsd-3-clause",
"hash": 8304519282148385000,
"line_mean": 24.5805084746,
"line_max": 81,
"alpha_frac": 0.4956104025,
"autogenerated": false,
"ratio": 2.899615754082613,
"... |
# 300. Longest Increasing Subsequence
#
# Given an unsorted array of integers, find the length of longest increasing subsequence.
# For example,
# Given [10, 9, 2, 5, 3, 7, 101, 18],
# The longest increasing subsequence is [2, 3, 7, 101], therefore the length is 4.
# Note that there may be more than one LIS combinatio... | {
"repo_name": "gengwg/leetcode",
"path": "300_longest_increasing_subsequence.py",
"copies": "1",
"size": "1282",
"license": "apache-2.0",
"hash": -8852912291516857000,
"line_mean": 31.8717948718,
"line_max": 89,
"alpha_frac": 0.5889235569,
"autogenerated": false,
"ratio": 3.40053050397878,
"con... |
# 303 - Range Sum Query Immutable (Easy)
# https://leetcode.com/problems/range-sum-query-immutable/
class NumArray(object):
def __init__(self, nums):
"""
initialize your data structure here.
:type nums: List[int]
"""
self.arr = []
acum = 0
self.arr.append(0)
... | {
"repo_name": "zubie7a/Algorithms",
"path": "LeetCode/01_Easy/lc_303.py",
"copies": "1",
"size": "1081",
"license": "mit",
"hash": -5537046844776160000,
"line_mean": 26.7435897436,
"line_max": 79,
"alpha_frac": 0.5605920444,
"autogenerated": false,
"ratio": 3.2560240963855422,
"config_test": fa... |
# 303. Range Sum Query - Immutable
# Given an integer array nums,
# find the sum of the elements between indices i and j (i ≤ j), inclusive.
# Example:
# Given nums = [-2, 0, 3, -5, 2, -1]
# sumRange(0, 2) -> 1
# sumRange(2, 5) -> -1
# sumRange(0, 5) -> -3
# Note:
# You may assume that the array does not chan... | {
"repo_name": "gengwg/leetcode",
"path": "303_range_sum_query_immutable.py",
"copies": "1",
"size": "1403",
"license": "apache-2.0",
"hash": -5491774437696001000,
"line_mean": 23.298245614,
"line_max": 77,
"alpha_frac": 0.5415162455,
"autogenerated": false,
"ratio": 2.564814814814815,
"config_t... |
# 304 Range Sum Query 2D - Immutable
#
# Given a 2D matrix matrix,
# find the sum of the elements inside the rectangle defined by
# its upper left corner (row1, col1) and lower right corner (row2, col2).
# Example:
# Given matrix = [
# [3, 0, 1, 4, 2],
# [5, 6, 3, 2, 1],
# [1, 2, 0, 1, 5],
# [4, 1, 0, 1, 7],
... | {
"repo_name": "gengwg/leetcode",
"path": "304_range_sum_query_2d_immutable.py",
"copies": "1",
"size": "1941",
"license": "apache-2.0",
"hash": -4026733841934629000,
"line_mean": 25.5362318841,
"line_max": 93,
"alpha_frac": 0.555434189,
"autogenerated": false,
"ratio": 2.3656330749354004,
"conf... |
# 30
# l 7
class Solution:
"""
@param A : a list of integers
@param target : an integer to be searched
@return : a list of length 2, [index1, index2]
"""
def searchRange(self, A, target):
# write your code here
if A is None or A == []:
return [-1, -1]
... | {
"repo_name": "stonemary/lintcode_solutions",
"path": "search-for-a-range/1.py",
"copies": "1",
"size": "1795",
"license": "apache-2.0",
"hash": -7719765717984588000,
"line_mean": 27.046875,
"line_max": 51,
"alpha_frac": 0.3799442897,
"autogenerated": false,
"ratio": 4.1841491841491845,
"config... |
"""31.0/.2015 PyOSE: Stacked exomoons with the Orbital Sampling Effect."""
import PyOSE
import matplotlib.pyplot as plt
import matplotlib.cm as cm
from matplotlib import rc
from numpy import pi
# Set stellar parameters
StellarRadius = 696342. # km
limb1 = 0.3643
limb2 = 0.2807
# Set planet parameters
#PlanetRadius... | {
"repo_name": "hippke/PyOSE",
"path": "CreateFigure3.py",
"copies": "1",
"size": "5893",
"license": "mit",
"hash": -5215666870820811000,
"line_mean": 34.7151515152,
"line_max": 81,
"alpha_frac": 0.7113524521,
"autogenerated": false,
"ratio": 2.7409302325581395,
"config_test": false,
"has_no_k... |
# 31.05.2007, c
# last revision: 25.02.2008
from __future__ import absolute_import
from sfepy import data_dir
filename_mesh = data_dir + '/meshes/2d/circle_sym.mesh'
material_1 = {
'name' : 'coef',
'values' : {
'val' : 1.0,
},
}
material_2 = {
'name' : 'm',
'values' : {
'K' : [[1.0... | {
"repo_name": "sfepy/sfepy",
"path": "tests/test_laplace_unit_disk.py",
"copies": "2",
"size": "3356",
"license": "bsd-3-clause",
"hash": -5126609553571748000,
"line_mean": 20.7922077922,
"line_max": 81,
"alpha_frac": 0.4988081049,
"autogenerated": false,
"ratio": 2.8013355592654423,
"config_te... |
# 310. Minimum Height Trees
# For an undirected graph with tree characteristics, we can choose any node as the root.
# The result graph is then a rooted tree. Among all possible rooted trees,
# those with minimum height are called minimum height trees (MHTs).
# Given such a graph, write a function to find all the MHTs... | {
"repo_name": "gengwg/leetcode",
"path": "310_minimum_height_trees.py",
"copies": "1",
"size": "2312",
"license": "apache-2.0",
"hash": -7914796982830569000,
"line_mean": 28.974025974,
"line_max": 217,
"alpha_frac": 0.5619584055,
"autogenerated": false,
"ratio": 3.1878453038674035,
"config_test... |
# 3/13/2016 copy from tcor_030525.py
# cd /Volumes/Transcend/SCAN_PROGRAM3
# python
import os
import sys
import cv2
import numpy as np
fscene=os.getcwd()
os.chdir('../Utility')
cwd=os.getcwd()
sys.path.append(cwd)
import rtc_util as ut
import tcor_util as tc
os.chdir(fscene)
#----------------------------
# Initiali... | {
"repo_name": "y-iikura/AtmosphericCorrection",
"path": "PostProcessing/post_reclss.py",
"copies": "1",
"size": "3811",
"license": "mit",
"hash": 8197105201693837000,
"line_mean": 26.615942029,
"line_max": 76,
"alpha_frac": 0.607189714,
"autogenerated": false,
"ratio": 2.3308868501529054,
"conf... |
# 313. Super Ugly Number
# Write a program to find the nth super ugly number.
#
# Super ugly numbers are positive numbers whose all prime factors are in the given prime list primes of size k.
#
# Example:
#
# Input: n = 12, primes = [2,7,13,19]
# Output: 32
# Explanation: [1,2,4,7,8,13,14,16,19,26,28,32] is the sequen... | {
"repo_name": "gengwg/leetcode",
"path": "313_super_ugly_number.py",
"copies": "1",
"size": "1740",
"license": "apache-2.0",
"hash": 3546217102709732400,
"line_mean": 31.1481481481,
"line_max": 135,
"alpha_frac": 0.5852534562,
"autogenerated": false,
"ratio": 3.1853211009174314,
"config_test": ... |
# 314. Binary Tree Vertical Order Traversal
# Given a binary tree, return the vertical order traversal of its nodes' values.
# (ie, from top to bottom, column by column).
# If two nodes are in the same row and column, the order should be from left to right.
# Examples:
#
# Given binary tree [3,9,20,null,null,15,... | {
"repo_name": "gengwg/leetcode",
"path": "314_binary_tree_vertical_order_traversal.py",
"copies": "1",
"size": "3410",
"license": "apache-2.0",
"hash": 1164314591294910200,
"line_mean": 23.8905109489,
"line_max": 131,
"alpha_frac": 0.5451612903,
"autogenerated": false,
"ratio": 3.178005591798695,... |
# 318. Maximum Product of Word Lengths
# Given a string array words, find the maximum value of length(word[i]) * length(word[j])
# where the two words do not share common letters.
# You may assume that each word will contain only lower case letters.
# If no such two words exist, return 0.
# Example 1:
# Input: ["... | {
"repo_name": "gengwg/leetcode",
"path": "318_Maximum_Product_of_Word_Lengths.py",
"copies": "1",
"size": "1557",
"license": "apache-2.0",
"hash": 8721006329104645000,
"line_mean": 27.3090909091,
"line_max": 90,
"alpha_frac": 0.5651894669,
"autogenerated": false,
"ratio": 3.1905737704918034,
"c... |
## 3.1 A First Individual
import random
from deap import base
from deap import creator
from deap import tools
IND_SIZE = 5
creator.create("FitnessMin", base.Fitness, weights=(-1.0, -1.0))
creator.create("Individual", list, fitness=creator.FitnessMin)
toolbox = base.Toolbox()
toolbox.register("attr_float", random.ra... | {
"repo_name": "DailyActie/Surrogate-Model",
"path": "docs/code/tutorials/part_3/3_next_step.py",
"copies": "2",
"size": "1495",
"license": "mit",
"hash": 6748982779075502000,
"line_mean": 24.3389830508,
"line_max": 68,
"alpha_frac": 0.7070234114,
"autogenerated": false,
"ratio": 2.820754716981132... |
31#Copyright (c) 2007-8, Playful Invention Company.
#Copyright (c) 2008-11, Walter Bender
#Copyright (c) 2011 Collabora Ltd. <http://www.collabora.co.uk/>
#Permission is hereby granted, free of charge, to any person obtaining a copy
#of this software and associated documentation files (the "Software"), to deal
#in the... | {
"repo_name": "walterbender/AmazonasTortuga",
"path": "TurtleArt/tacanvas.py",
"copies": "2",
"size": "14965",
"license": "mit",
"hash": -1116941944366732400,
"line_mean": 34.4620853081,
"line_max": 79,
"alpha_frac": 0.5347143334,
"autogenerated": false,
"ratio": 3.171894870707927,
"config_test... |
#31-Game
#PythonLab
import random as R
def createDeck():
return [i for i in range(1,15)]
deck = [ createDeck(),createDeck(),
createDeck(),createDeck() ]
Exit = False
while not Exit:
cards = []
mother = []
s = 0
choice = raw_input("Do you want to play? ")
if choice == 'yes' or ... | {
"repo_name": "georgezafiris/python-lab",
"path": "cs2_thirtyone_game.py",
"copies": "1",
"size": "1729",
"license": "mit",
"hash": -8573842265179196000,
"line_mean": 24.8059701493,
"line_max": 70,
"alpha_frac": 0.4117987276,
"autogenerated": false,
"ratio": 4.227383863080685,
"config_test": fa... |
# #3.1
# names=['zhang dongzhou','jiang miaoshan','zhang qiyang','zhang yifeng','zhang tong']
# def T(a):
# return str(a.title())
# message=T(names[0])+"\tand\t"+T(names[-4])+"\tis\t"+T(names[2])+","+T(names[3])+"\tand\t"+T(names[-1])+"'s parents!"
# print("It is the most important that\n",message)
# #3.2[列表元素的添加,修... | {
"repo_name": "Tiger-C/python",
"path": "3/3.py",
"copies": "1",
"size": "1562",
"license": "mit",
"hash": -8494961630740106000,
"line_mean": 29.8780487805,
"line_max": 153,
"alpha_frac": 0.6753554502,
"autogenerated": false,
"ratio": 1.8059914407988589,
"config_test": false,
"has_no_keywords... |
# 320. Generalized Abbreviation
# Write a function to generate the generalized abbreviations of a word.
# Example:
# Given word = "word", return the following list (order does not matter):
# ["word", "1ord", "w1rd", "wo1d", "wor1", "2rd", "w2d", "wo2", "1o1d", "1or1", "w1r1", "1o2", "2r1", "3d", "w3", "4"]
class Sol... | {
"repo_name": "gengwg/leetcode",
"path": "320_generalized_abbreviation.py",
"copies": "1",
"size": "2200",
"license": "apache-2.0",
"hash": 2368717046090383000,
"line_mean": 30.4285714286,
"line_max": 118,
"alpha_frac": 0.5181818182,
"autogenerated": false,
"ratio": 3.536977491961415,
"config_t... |
# 322. Coin Change
# You are given coins of different denominations and a total amount of money amount. Write a function to compute the fewest number of coins that you need to make up that amount. If that amount of money cannot be made up by any combination of the coins, return -1.
# Example 1:
# coins = [1, 2, 5], a... | {
"repo_name": "gengwg/leetcode",
"path": "322_coin_change.py",
"copies": "1",
"size": "1535",
"license": "apache-2.0",
"hash": 5479912583752918000,
"line_mean": 36.4390243902,
"line_max": 264,
"alpha_frac": 0.5732899023,
"autogenerated": false,
"ratio": 3.238396624472574,
"config_test": false,
... |
# 323 Number of Connected Components in an Undirected Graph
# Given n nodes labeled from 0 to n-1 and a list of undirected edges (each edge is a pair of nodes),
# write a function to find the number of connected components in an undirected graph.
#
# Example 1:
#
# 0 3
# | |
# 1 --- 2 ... | {
"repo_name": "gengwg/leetcode",
"path": "323_number_of_connected_components_in_an_undirected_graph.py",
"copies": "1",
"size": "1439",
"license": "apache-2.0",
"hash": 1300470461648253700,
"line_mean": 29.6170212766,
"line_max": 116,
"alpha_frac": 0.510771369,
"autogenerated": false,
"ratio": 3.... |
# 324. Wiggle Sort II
# Given an unsorted array nums, reorder it such that nums[0] < nums[1] > nums[2] < nums[3]....
#
# Example 1:
#
# Input: nums = [1, 5, 1, 1, 6, 4]
# Output: One possible answer is [1, 4, 1, 5, 1, 6].
#
# Example 2:
#
# Input: nums = [1, 3, 2, 2, 3, 1]
# Output: One possible answer is [2, 3, 1, 3,... | {
"repo_name": "gengwg/leetcode",
"path": "324_wiggle_sort_ii.py",
"copies": "1",
"size": "1131",
"license": "apache-2.0",
"hash": 33473013736526304,
"line_mean": 24.1333333333,
"line_max": 94,
"alpha_frac": 0.5128205128,
"autogenerated": false,
"ratio": 2.9149484536082473,
"config_test": false,... |
# 329-longest-increasing-path-in-matrix.py
class Solution(object):
def longestIncreasingPath_wa(self, matrix): # Wrong Answer, need 4 directions
"""
:type matrix: List[List[int]]
:rtype: int
"""
if len(matrix) == 0: return 0
d1 = [[1] * len(matrix[0]) for _ in matrix... | {
"repo_name": "daicang/Leetcode-solutions",
"path": "329-longest-increasing-path-in-matrix.py",
"copies": "1",
"size": "2949",
"license": "mit",
"hash": -2003808647158119700,
"line_mean": 48.15,
"line_max": 532,
"alpha_frac": 0.4513394371,
"autogenerated": false,
"ratio": 2.676043557168784,
"co... |
"""32bit ARM/NEON assembly emitter.
Used by code generators to produce ARM assembly with NEON simd code.
Provides tools for easier register management: named register variable
allocation/deallocation, and offers a more procedural/structured approach
to generating assembly.
TODO: right now neon emitter prints out asse... | {
"repo_name": "shishaochen/TensorFlow-0.8-Win",
"path": "third_party/gemmlowp/meta/generators/neon_emitter.py",
"copies": "5",
"size": "22203",
"license": "apache-2.0",
"hash": 8112293378004539000,
"line_mean": 34.5817307692,
"line_max": 80,
"alpha_frac": 0.604152592,
"autogenerated": false,
"rat... |
32"""
Creates th WAVES.for mesh for a
square domain under a point load.
@autor Juan Gomez
"""
from __future__ import division
import meshio
import mesh_waves as msw
import numpy as np
import fileinput
import glob
#%%
points, cells, point_data, cell_data , field_data = \
meshio.read("transparency.msh")
#
nodes_array... | {
"repo_name": "jgomezc1/WAVES",
"path": "MODELS/MESHER/transparency_input.py",
"copies": "1",
"size": "1076",
"license": "mit",
"hash": 5631720392737371000,
"line_mean": 26.6153846154,
"line_max": 94,
"alpha_frac": 0.6459107807,
"autogenerated": false,
"ratio": 2.5619047619047617,
"config_test"... |
#32 - Top Scores.py
# You rank players in the game from highest to lowest score. So far you're using an algorithm that sorts in O(n\lg{n})O(nlgn) time, but players are complaining that their rankings aren't updated fast enough. You need a faster sorting algorithm.
# Write a function that takes:
# a list of unsorted_... | {
"repo_name": "bruno615/one-off-analysis",
"path": "Python/Inteview Cake/32 - Top Scores.py",
"copies": "1",
"size": "1084",
"license": "mit",
"hash": 6049270699746267000,
"line_mean": 28.2972972973,
"line_max": 244,
"alpha_frac": 0.7029520295,
"autogenerated": false,
"ratio": 3.335384615384615,
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.