<jupyter_start><jupyter_text>Functions of Numpy 5<jupyter_code>import numpy as np
import pandas as pd
from pandas import DataFrame, Series
import matplotlib.pyplot as plt
import random
num=np.array(['3.14','-2.7','30'],dtype=np.string_)
num=num.astype(float).astype(int)
print(num)
arr=np.arange(32).reshape((8,4))
print(arr)
print(arr[[1,5,7,2],[0,3,1,2]])
print(arr[[1,5,7,2]][:,[0,3,1,2]])
position=0
walk=[]
steps=1000
for i in range(steps):
    step = 1 if random.randint(0,1) else -1
    position+=step
    walk.append(position)
print("position : ",position)
print("walk : ",walk)
print(min(walk))
print(max(walk))
print(np.abs(walk))<jupyter_output>[ 1  2  1  0  1  0  1  2  1  2  3  2  3  2  3  2  3  4  5  4  3  4  5  6
  5  6  7  6  5  6  7  8  7  8  7  6  7  6  7  8  7  8  7  8  7  6  5  6
  7  6  5  4  3  2  3  4  3  4  5  4  5  6  5  6  5  6  7  8  7  6  5  6
  7  8  7  8  9  8  9  8  9 10  9 10  9  8  9 10  9 10 11 10 11 10  9 10
 11 10 11 12 13 12 13 12 11 12 11 10  9 10 11 12 13 14 15 16 15 14 13 14
 15 16 17 16 15 16 17 16 15 16 15 16 15 16 17 16 17 18 17 18 17 16 17 18
 19 18 19 18 19 20 21 20 19 18 19 20 19 18 17 18 17 16 17 16 15 16 17 18
 19 18 19 20 19 18 17 16 17 18 19 18 17 18 19 18 17 18 17 16 15 14 15 16
 17 18 17 16 15 16 17 16 17 18 19 20 19 20 21 22 21 22 23 22 21 22 23 24
 23 22 23 22 23 24 25 24 25 26 25 26 25 24 25 24 25 24 23 24 25 26 25 24
 23 22 23 24 25 26 25 24 23 24 25 26 25 24 23 24 23 22 23 24 25 24 25 26
 25 24 23 22 21 20 21 20 19 20 19 20 19 18 17 16 15 14 15 14 15 16 17 16
 15 16 17 18 19 18 17 16 15 16 17 18 17 16 15 14 13 14 13 12 11 10 11 10
  9  8  7  6  5  6  7  8  7  8  7  8  9 10 11 12 13[...]<jupyter_text>=====================================================================================<jupyter_code>obj=Series([1,2,-3,4])
print(obj)
print(obj.values)
print(obj.index)
obj=Series([1,2,-3,4], index=['x','y','z','k'])
print(obj)
print(obj['y'])
obj['x']=10
print(obj)
print(obj[['x','y','z']])
print(obj>0)
print(obj[obj>0])
print(obj*2)
print(np.exp(obj))
print(obj)
print('a' in obj)
print('x' in obj)<jupyter_output>True<jupyter_text>==================================================================================<jupyter_code>sdata={'Ohio': 35000, 'Texas': 71000, 'Oregon': 16000, 'Utah': 5000}
obj3=Series(sdata)
print(obj3)
print(type(obj3))
states = ['California','Ohio','Oregon','Texas']
obj99=Series(states)
print(obj99)
obj4=Series(sdata, index=states)
print(obj4)
print(pd.isnull(obj4))
print(obj3+obj4)
obj4.name='population'
obj.index.name='stae'
print(obj4)
obj4.index=['w','x','y','z']
print(obj4)<jupyter_output>w        NaN
x    35000.0
y    16000.0
z    71000.0
Name: population, dtype: float64<jupyter_text>==================================================================================<jupyter_code>data={
    'state':['Ohio', 'Ohio', 'Ohio', 'Ohio', 'Nevead'],
    'year':[2000, 2001, 2002, 2001, 2002],
    'pop':[1.5, 1.7, 3.6, 2.4, 2.9]}
frame = DataFrame(data)
print(frame)
frame=DataFrame(data, columns=['year', 'state', 'pop'])
print(frame)
frame2=DataFrame(data, 
    columns=['year', 'state', 'pop', 'debt'], index=['one', 'two', 'three', 'four', 'five'])
print(frame2)
print(frame2['state'])
print(frame2['year'])
print(frame2.loc['three'])
print(frame2.loc[['three', 'five']])
frame2['debt']=16.5
print(frame2)
frame2['debt']=np.arange(5)
print(frame2)
val=Series([-1.2, -1.5, -1.7],
           index=['two', 'four', 'five'])
frame2['debt']=val
print(frame2)
frame2['eastern']=frame2.state=='Ohio'
print(frame2)
del frame2['eastern']
print(frame2)
print(frame2.columns)
print(frame2.index)
pop={'Nevada':{2001:2.4, 2002:2.9},
     'Ohio': {2000:1.5, 2001:2.7, 2002: 3.6}}
frame3=DataFrame(pop)
print(frame3)
print(frame3.T)
frame4=DataFrame(frame3, index=['2001', '2002', '2003'])
print(frame4)
pdata={'Ohio':frame3['Ohio'][:-1],
       'Nevada': frame3['Nevada'][:2]}
frame5=DataFrame(pdata)
print(frame5)<jupyter_output>Ohio  Nevada
2000   1.5     NaN
2001   2.7     2.4
{'fraction_non_alphanumeric': 0.22325464590657962, 'fraction_numerical': 0.1981416373681567, 'mean_word_length': 4.119537275064268, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 15, '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': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '396227', 'license': 'MIT', 'n_tokens_mistral': 2210, 'n_tokens_neox': 1625, 'n_words': 521, 'path': 'Numpy_5.ipynb', 'repo_name': 'heejinADP/TIL', 'size': '3982'}