<jupyter_start><jupyter_text><jupyter_code># import the pandas 
# using for descibe or show the data 
import numpy as np 
import pandas as pd 
card_dataset = pd.read_csv('/content/creditcard.csv')
# Print firts 5 rows of the dataset 
card_dataset.head()
# Print some rows of the dataset 
card_dataset.head(10)
# Print last 5 rows of the dataset 
card_dataset.tail()
card_dataset.tail(10)
card_dataset.shape
card_dataset.info()
# Print all columns name
card_dataset.columns
# Print the index 
card_dataset.index
card_dataset.describe()<jupyter_output><empty_output><jupyter_text>LOC and iloc (location and )<jupyter_code>card_dataset
# Filter some rows with conditions
card_dataset.loc[card_dataset.V1 == 1.960497 ]
card_dataset.iloc[9]
card_dataset.Time.apply(lambda x : x -1  )
# Create New Columns by mutiplication two columns together 
card_dataset['V1_V2'] = card_dataset['V1']*card_dataset['V2']
sum_v1 = card_dataset['V1'].sum()
print(sum_v1)<jupyter_output>-7449.5839914563<jupyter_text>Group by<jupyter_code>card_dataset.value_counts()
card_dataset.value_counts().count()
card_dataset.V1.nunique()
card_dataset.V1.unique()<jupyter_output><empty_output><jupyter_text>NUMPY<jupyter_code># Creating numpy arrays from Python Lists 
print(np.array([1, 2, 3, 4]))<jupyter_output>[1 2 3 4]<jupyter_text>Creating Numpy arrays from Scratch Zeros, ones, full, arrange, linsapace<jupyter_code>np.zeros([2,4], dtype= int )
np.ones([3,5], dtype = float)
print(np.arange(0, 20, 2))
np.full([4, 5], 6.9)
np.linspace(0, 1, 5)<jupyter_output><empty_output><jupyter_text>random array<jupyter_code># make random array
np.random.random([4, 4])
np.random.random([4, 4])
# Seed for reproducibility 
np.random.seed(0)

np.random.random([4, 4])
np.random.random([4, 4])
np.random.normal(0, 1, [3, 3])
np.random.rand(4, 4)<jupyter_output><empty_output><jupyter_text>**Array Indexing and Slicing ** one-dimensional subarry<jupyter_code># One-dimensional subarray
arr_ran = np.random.randint(20, size = 6)
print(arr_ran)
print(arr_ran[1], arr_ran[-1], arr_ran[3])
# Multi-dimensional array 
arr_ran_multi = np.random.randint(30, size = (3, 4))
print(arr_ran_multi)
# Slicing 
print(*arr_ran)
print(*arr_ran[0:3])
print(arr_ran_multi)
print(arr_ran_multi[:2,:3])
# Reshape
grid = np.arange(1, 10)
grid.shape
grid.reshape((3, 3))
x = np.array([1, 2, 3])
x.shape 
x.reshape((1, 3)).shape<jupyter_output><empty_output><jupyter_text>Array Concatenation and Spliting<jupyter_code>x_arr = np.array([1, 2, 3])
y_arr = np.array([3, 2, 1])
np.concatenate((x_arr, y_arr))
grid  = np.array([[1,2,3],
               [4,5,6]])
    
grid<jupyter_output><empty_output><jupyter_text>Broadcasting and Vectorized operations<jupyter_code>a = np.arange(3)
print(*a)
print(*(a + 5))<jupyter_output>5 6 7<jupyter_text>Manipulating and Comparing  Sorting<jupyter_code>x = np.array([2, 1, 3, 5, 4])
print(x)
x.sort()
print(x)<jupyter_output>[1 2 3 4 5]<jupyter_text>**MATPLOTLIB**<jupyter_code># Importing the dependences
import math 
import numpy as np 
import pandas as pd 
import matplotlib.pyplot as plt

plt.plot()
x= [15, 30 ,15]
y= [15, 90, 120]
plt.plot(x, y, color= 'red')
plt.show()<jupyter_output><empty_output><jupyter_text>Pyplot API và Object Orientrd API<jupyter_code>x = np.linspace(0, 10, 1000)
print(x)
plt.plot(x, np.sin(x), color='green');
plt.xlabel('Bien X')
plt.ylabel('SIN(x)')
x= [1, 2, 3, 4]
y= [11,22,33,44]

# Set up plot 
fig, ax= plt.subplots(figsize= (5, 5))

ax.plot(x, y);

ax.set(title = 'A simple plot',
       xlabel ='X', 
       ylabel = 'Y');<jupyter_output><empty_output><jupyter_text>Most common types of Mathploylib plots*line*scatter *bar *hist *subplots<jupyter_code># Line 
x = np.linspace(0, 10, 100)

# oop plot the line 

fig, ax = plt.subplots()
ax.plot(x, x**3)<jupyter_output><empty_output><jupyter_text>Scatter<jupyter_code># Pyplot API 
plt.scatter(x, x**3)
# OO API

# Prepare the new data 
rng = np.random.RandomState(0)

x = rng.random(100)
y = rng.random(100)
colors = rng.rand(100)
sizes = 1000*rng.random(100)

fix, ax = plt.subplots()
ax.scatter(x, y, s= sizes, c= colors);<jupyter_output><empty_output><jupyter_text>Bar * Vertical * Horizontal<jupyter_code># Prepare data 
soft_drink_prices = {
    "Coca Cola" : 10,
    "Pessi" : 12,
    "SPrite" : 5
}

fig, ax = plt.subplots()
ax.bar(soft_drink_prices.keys(), soft_drink_prices.values());<jupyter_output><empty_output><jupyter_text>PROJECT : Data Visualization<jupyter_code>import math 
import numpy as np 
import matplotlib.pyplot as plt
import pandas as pd 
cali_dataset = pd.read_csv('/content/california_cities.csv')
print(cali_dataset.shape)
cali_dataset
cali_dataset.head()
# Extract Lad longd (Kinh do va vi do)

lat, lon = cali_dataset['latd'], cali_dataset['longd']
print(lat)
print(lon)
population, area = cali_dataset['population_total'], cali_dataset['area_land_km2']
plt.scatter(lon, lat,
            c = np.log10(population), cmap = 'viridis')

plt.axis('equal')
plt.xlabel('longlatutide')
plt.ylabel('latitude')
plt.colorbar(label='Poplation')<jupyter_output><empty_output><jupyter_text>Seaborn<jupyter_code>import pandas as pd 
import numpy as np
import matplotlib as plt 
import seaborn as sns<jupyter_output><empty_output><jupyter_text>Numerical Plots<jupyter_code>tips_dataset = sns.load_dataset('tips')
tips_dataset.head()
tips_dataset.value_counts()
tips_dataset.describe()
sns.histplot(data = tips_dataset['total_bill'])
tips_dataset['total_bill'].value_counts().sort_values()
sns.kdeplot(data= tips_dataset['total_bill'])
print(sns.get_dataset_names())
sns.displot(data= tips_dataset, x= 'total_bill', col= 'time', kde = True)<jupyter_output><empty_output><jupyter_text>Bar Plots<jupyter_code>tips_dataset.head()
sns.barplot(data= tips_dataset, x= 'sex', y = 'tip', estimator=np.mean)<jupyter_output><empty_output><jupyter_text>Count Plot<jupyter_code>tips_dataset['sex'].value_counts()
sns.countplot(data = tips_dataset, x= 'sex')<jupyter_output><empty_output><jupyter_text>Box Plot<jupyter_code>sns.boxplot(data= tips_dataset, x='day', y = 'total_bill', hue = 'sex')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.15038581513708751, 'fraction_numerical': 0.03201444754555902, 'mean_word_length': 6.84041184041184, 'pattern_counts': {'":': 0, '<': 81, '<?xml version=': 0, '>': 81, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '21', 'dir': 'jupyter-structured-clean-dedup', 'id': '451145', 'license': 'Apache-2.0', 'n_tokens_mistral': 2634, 'n_tokens_neox': 2472, 'n_words': 472, 'path': 'Anything_in_here.ipynb', 'repo_name': 'DgBack/Data_Visualization-', 'size': '6091'}