This file contains 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
data.groupby(['name', pd.Grouper(key='date', freq='M')])['ext price'].sum() |
This file contains 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
data.groupby(['name', pd.Grouper(key='date', freq='M')])['ext price'].sum().unstack() |
This file contains 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
%matplotlib notebook | |
import matplotlib.pyplot as plt | |
# scatter plot of some data # try this on your dataset | |
plt.scatter(data['quantity'],data['unit price']) |
This file contains 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
%%time | |
def myfunction(x) : | |
for i in range(1,100000,1) : | |
i=i+1 |
This file contains 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
%load_ext rpy2.ipython | |
%R require(ggplot2) |
This file contains 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 pandas as pd | |
df = pd.DataFrame({ | |
'Class': ['A', 'A', 'A', 'V', 'V', 'A', 'A', 'A'], | |
'X': [4, 3, 5, 2, 1, 7, 7, 5], | |
'Y': [0, 4, 3, 6, 7, 10, 11, 9], | |
'Z': [1, 2, 3, 1, 2, 3, 1, 2] | |
}) |
This file contains 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
%%R -i df | |
ggplot(data = df) + geom_point(aes(x = X, y= Y, color = Class, size = Z)) |
This file contains 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
# importing libraries | |
import pandas as pd | |
data = pd.read_csv('school.csv') | |
data.head() |
This file contains 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
# save the top cities in a list | |
top_cities = ['Brooklyn','Bronx','Manhattan','Jamaica','Long Island City'] | |
# use loc to update the target | |
data.loc[(data.City.isin(top_cities) == False),'City'] = 'Others' | |
# city value counts | |
data.City.value_counts() |
This file contains 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
# importing required libraries | |
import pandas as pd | |
import math | |
import multiprocessing as mp | |
from random import randint | |
# function to calculate the number of divisors | |
def countDivisors(n) : | |
count = 0 | |
for i in range(1, (int)(math.sqrt(n)) + 1) : |