Parallel Inner Products

In [1]: from IPython.parallel import Client, require, interactive In [5]: rc = Client() dv = rc.direct_view() lv = rc.load_balanced_view() In [6]: with dv.sync_imports(): import numpy importing numpy on engine(s) In [7]: mat = numpy.random.random_sample((800, 800)) mat = numpy.asfortranarray(mat) In [8]: def simple_inner(i): column = mat[:, i] # have to use a list comprehension to prevent closure return sum([numpy.inner(column, mat[:, j])… Continue reading Parallel Inner Products

Diagnosing Slow Parallel Inner Products

In [1]: from IPython.parallel import Client, require, interactive In [2]: rc = Client() dv = rc.direct_view() lv = rc.load_balanced_view() In [3]: with dv.sync_imports(): import numpy importing numpy on engine(s) In [4]: mat = numpy.random.random_sample((800, 800)) mat = numpy.asfortranarray(mat) In [5]: def simple_inner(i): column = mat[:, i] # have to use a list comprehension to prevent closure return sum([numpy.inner(column, mat[:, j])… Continue reading Diagnosing Slow Parallel Inner Products

Read Csv Uisng Pandas Code Example

Snippet 1 pd.read_csv(‘data.csv’) # doctest: +SKIP Snippet 2 import pandas as pd df = pd.read_csv (r’Path where the CSV file is storedFile name.csv’) print (df) Snippet 3 you should be in the same dir as .py file df = pd.read_csv(‘your_file_name.csv’) Snippet 4 import pandas as pd #import pandas #syntax: pd.read_csv(‘file_location/file_name.csv’) data = pd.read_csv(‘filelocation/fileName.csv’) #reading data… Continue reading Read Csv Uisng Pandas Code Example

Remove 1st Column Pandas Code Example

Snippet 1 df.drop(‘col_name’,1) #1 drop column / 0 drop row Snippet 2 To delete rows and columns from DataFrames, Pandas uses the “drop” function. To delete a column, or multiple columns, use the name of the column(s), and specify the “axis” as 1. Snippet 3 df = df.drop(df.columns[[0, 1, 3]], axis=1) # df.columns is zero-based… Continue reading Remove 1st Column Pandas Code Example

Latihan

Latihan Buatlah variabel dengan nama hobi, yang digunakan untuk menampung input dari user dengan label “Hobi kamu apa? : ” , kemudian Cetaklah dengan label Hobi kamu : {hobi} Buatlah variabel nama, yang digunakan untuk menampung input dari user dengan label “Siapa nama kamu? : ” , misal user mengisikan nama “Romi” maka akan tampil… Continue reading Latihan

Data Profiling

In [1]: import pandas as pd import numpy as np import matplotlib.pyplot as plt %matplotlib inline import seaborn as sns from sklearn.preprocessing import OrdinalEncoder from sklearn.preprocessing import OneHotEncoder from sklearn.preprocessing import StandardScaler from sklearn.model_selection import train_test_split from sklearn.ensemble import ExtraTreesClassifier import warnings warnings.filterwarnings(‘ignore’) In [2]: df = pd.read_csv(‘data_telco.csv’) In [3]: df.head() Out[3]: customerID gender SeniorCitizen Partner Dependents tenure… Continue reading Data Profiling

Rename Row Pandas Code Example

Snippet 1 df.rename(columns={“A”: “a”, “B”: “b”, “C”: “c”}, errors=”raise”, inplace=True) Snippet 2 >>> df.rename({1: 2, 2: 4}, axis=’index’) A B 0 1 4 2 2 5 4 3 6 Similar Snippets Rename Row Pandas Code Example – pandas Pandas Iterrows Code Example – pandas Slicing In Pandas Code Example – pandas Pandas Count Rows With… Continue reading Rename Row Pandas Code Example