投稿時間:2023-01-09 14:08:26 RSSフィード2023-01-09 14:00 分まとめ(10件)
カテゴリー等 | サイト名等 | 記事タイトル・トレンドワード等 | リンクURL | 頻出ワード・要約等/検索ボリューム | 登録日 |
---|---|---|---|---|---|
js | JavaScriptタグが付けられた新着投稿 - Qiita | fetch APIとPromiseの備忘録 | https://qiita.com/be834194/items/f9c95470246126f4bf9d | fetchapi | 2023-01-09 13:10:41 |
海外TECH | DEV Community | NumPy 101: A Beginner's Guide to Data Science with Python | https://dev.to/anurag629/numpy-101-a-beginners-guide-to-data-science-with-python-49an | NumPy A Beginner x s Guide to Data Science with Python Day of Days Data Science Bootcamp from noob to expert GitHub link Complete Data Science Bootcamp Main Post Complete Data Science Bootcamp Recap Day Yesterday we have studied in detail about OOPs in Python Let s StartNumPy is a library in Python that provides fast and efficient numerical operations on arrays It is used extensively in data science and machine learning to perform mathematical operations on large datasets Python list vs NumPy arraysNumPy arrays are similar to Python lists but they are more efficient and can perform operations faster NumPy arrays are homogenous meaning they can only contain elements of the same data type while Python lists can contain elements of different data types NumPy arrays also have a fixed size while Python lists do not Creating a NumPy ArrayThere are several ways to create a NumPy array Basic ndarray To create a basic NumPy array we can use the numpy array function For example import numpy as npa np array print a Array of zeros To create an array of zeros we can use the numpy zeros function For example a np zeros print a Array of ones To create an array of ones we can use the numpy ones function For example a np ones print a Random numbers in ndarray To create an array of random numbers we can use the numpy random rand function For example a np random rand print a An array of your choice To create an array with specific values we can use the numpy arange function For example a np arange print a Matrix in NumPy To create a D array matrix we can use the numpy matrix function For example a np matrix print a Evenly spaced ndarray To create an array with evenly spaced values we can use the numpy linspace function For example a np linspace print a Shape and Reshaping of NumPy ArrayDimensions of NumPy array To get the dimensions of a NumPy array we can use the ndarray ndim attribute For example a np array print a ndim Shape of NumPy array To get the shape of a NumPy array we can use the ndarray shape attribute For example print a shape Size of NumPy array To get the total number of elements in a NumPy array we can use the ndarray size attribute For example print a size Reshaping a NumPy array To reshape a NumPy array we can use the ndarray reshape function For example a np array b a reshape print b Flattening a NumPy array To flatten a NumPy array we can use the ndarray flatten function For example a np array b a flatten print b Transpose of a NumPy array To get the transpose of a NumPy array we can use the ndarray transpose function For example a np array b a transpose print b Expanding and Squeezing a NumPy ArrayTo expand a NumPy array we can use the numpy expand dims function For example a np array b np expand dims a axis print b To squeeze a NumPy array we can use the numpy squeeze function For example a np array b np squeeze a print b Indexing and Slicing of NumPy ArraySlicing D NumPy arrays To slice a D NumPy array we can use the ndarray start end step notation For example a np array b a print b Slicing D NumPy arrays To slice a D NumPy array we can use the ndarray row start row end row step col start col end col step notation For example a np array b a print b Slicing D NumPy arrays To slice a D NumPy array we can use the ndarray dim start dim end dim step dim start dim end dim step dim start dim end dim step notation For example a np array b a print b Negative slicing of NumPy arrays To slice a NumPy array with negative indices we can use the ndarray end start step notation For example a np array b a print b Stacking and Concatenating Numpy ArraysStacking ndarrays To stack NumPy arrays vertically or horizontally we can use the numpy vstack or numpy hstack functions For example a np array b np array c np vstack a b d np hstack a b print c print d Concatenating ndarrays To concatenate NumPy arrays along a specific axis we can use the numpy concatenate function For example a np array b np array c np concatenate a b axis print c Broadcasting in Numpy ArraysBroadcasting is a powerful feature in NumPy that allows us to perform arithmetic operations on arrays of different shapes NumPy automatically broadcasts smaller arrays to match the shape of larger arrays in order to perform operations For example a np array b np array c a bprint c NumPy UfuncsNumPy provides a wide range of universal functions ufuncs that can be applied to arrays to perform mathematical operations Some common ufuncs include np add Adds two arrays element wisenp subtract Subtracts two arrays element wisenp multiply Multiplies two arrays element wisenp divide Divides two arrays element wisenp abs Calculates the absolute value of an arraynp sin Calculates the sine of an arraynp cos Calculates the cosine of an arraynp exp Calculates the exponent of an arraya np array b np array c np add a b d np subtract a b e np multiply a b f np divide a b g np abs a h np sin a i np cos a j np exp a print c print d print e print f print g print h print i print j Maths with NumPy ArraysNumPy provides many functions to perform mathematical operations on arrays Some common functions include np mean Calculates the mean of an arraynp median Calculates the median of an arraynp std Calculates the standard deviation of an arraynp min Calculates the minimum value of an arraynp max Calculates the maximum value of an arraynp argmin Calculates the index of the minimum value of an arraynp argmax Calculates the index of the maximum value of an arraynp sort Sorts an array in ascending ordera np array mean np mean a median np median a std np std a min val np min a max val np max a min index np argmin a max index np argmax a sorted a np sort a print mean print median print std print min val print max val print min index print max index print sorted a NumPy Arrays and ImagesNumPy arrays can be used to represent images To read an image into a NumPy array we can use the scipy misc imread function To write a NumPy array as an image we can use the scipy misc imsave function import numpy as npimport imageio Read image into NumPy arrayimg imageio imread image jpeg Perform some operations on the imageimg img Save the modified imageimageio imsave modified image jpeg img To display the image using matplotlib you can use the same code as before import numpy as npimport matplotlib pyplot as plt Read image into NumPy arrayimg imageio imread image jpeg Display imageplt imshow img plt show After Image Read image into NumPy arrayimg imageio imread modified image jpeg Display imageplt imshow img plt show Exercise Question you will find in the exercise notebook of Day on GitHub If you liked it then | 2023-01-09 04:16:36 |
海外TECH | CodeProject Latest Articles | Rust Microservices in Server-side WebAssembly | https://www.codeproject.com/Articles/5350228/Rust-Microservices-in-Server-side-WebAssembly | microservices | 2023-01-09 04:34:00 |
海外ニュース | Japan Times latest articles | Japan to build up defenses from 2023, with China and North Korea in mind | https://www.japantimes.co.jp/news/2023/01/09/national/japan-defense-posture-2023/ | nuclear | 2023-01-09 13:39:57 |
海外ニュース | Japan Times latest articles | China conducts large-scale joint ‘combat’ drill around Taiwan | https://www.japantimes.co.jp/news/2023/01/09/asia-pacific/china-taiwan-adiz-kevin-mccarthy/ | China conducts large scale joint combat drill around TaiwanChina sent a contingent of warplanes around Taiwan in the hours through Monday morning just days after new U S House Speaker Kevin McCarthy | 2023-01-09 13:10:14 |
ニュース | BBC News - Home | Brazil Congress: Lula vows to punish supporters of Bolsonaro after riot | https://www.bbc.co.uk/news/world-latin-america-64204860?at_medium=RSS&at_campaign=KARANGA | court | 2023-01-09 04:37:09 |
ニュース | BBC News - Home | Pandemic care home death: Family to sue over mother's end-of-life consent | https://www.bbc.co.uk/news/uk-64164338?at_medium=RSS&at_campaign=KARANGA | consenttony | 2023-01-09 04:15:29 |
北海道 | 北海道新聞 | 鳥インフル、処分数最多に 計998万羽、茨城で確認 | https://www.hokkaido-np.co.jp/article/784961/ | 今シーズン | 2023-01-09 13:16:47 |
北海道 | 北海道新聞 | ヘンドリックス、がん公表 Wソックス投手 | https://www.hokkaido-np.co.jp/article/784980/ | 大リーグ | 2023-01-09 13:31:00 |
北海道 | 北海道新聞 | 自民、大物の調整難航 衆院選挙区、1減となる10県の多くで現職ひしめく 立憲・公明、増員区で積極擁立へ | https://www.hokkaido-np.co.jp/article/784903/ | 小選挙区 | 2023-01-09 13:23:51 |
コメント
コメントを投稿