Numpy MaskedArray asanyarray() method | Python Last Updated : 16 Nov, 2021 Comments Improve Suggest changes Like Article Like Report numpy.ma.asanyarray() function is used when we want to convert input to a masked array, conserving subclasses. If arr is a subclass of MaskedArray, its class is conserved. No copy is performed if the input is already an ndarray. Syntax : numpy.ma.asanyarray(arr, dtype=None) Parameters : arr : [array_like] Input data, in any form that can be converted to a masked array. dtype : [data-type, optional] By default, the data-type is inferred from the input data. order : Whether to use row-major (C-style) or column-major (Fortran-style) memory representation. Defaults to āCā. Return : [MaskedArray] Masked array interpretation of arr. Code #1 : Python3 # Python program explaining # numpy.ma.asanyarray() function import numpy as geek my_list = [1, 4, 8, 7, 2, 5] print ("Input list : ", my_list) out_arr = geek.ma.asanyarray(my_list) print ("output array from input list : ", out_arr) Output : Input list : [1, 4, 8, 7, 2, 5] output array from input list : [1 4 8 7 2 5] Code #2 : Python3 # Python program explaining # numpy.ma.asanyarray() function import numpy as geek my_tuple = ([1, 4, 8], [7, 2, 5]) print ("Input tuple : ", my_tuple) out_arr = geek.ma.asanyarray(my_tuple) print ("output array from input tuple : ", out_arr) Output : Input tuple : ([1, 4, 8], [7, 2, 5]) output array from input tuple : [[1 4 8] [7 2 5]] Comment More info S sanjoy_62 Follow Improve Article Tags : Machine Learning Python-numpy python Python Numpy-Masked Array Explore Machine Learning BasicsIntroduction to Machine Learning8 min readTypes of Machine Learning13 min readWhat is Machine Learning Pipeline?7 min readApplications of Machine Learning3 min readPython for Machine LearningMachine Learning with Python Tutorial5 min readNumPy Tutorial - Python Library3 min readPandas Tutorial6 min readData Preprocessing in Python3 min readEDA - Exploratory Data Analysis in Python6 min readFeature EngineeringWhat is Feature Engineering?5 min readIntroduction to Dimensionality Reduction4 min readFeature Selection Techniques in Machine Learning6 min readSupervised LearningSupervised Machine Learning7 min readLinear Regression in Machine learning15+ min readLogistic Regression in Machine Learning11 min readDecision Tree in Machine Learning9 min readRandom Forest Algorithm in Machine Learning5 min readK-Nearest Neighbor(KNN) Algorithm8 min readSupport Vector Machine (SVM) Algorithm9 min readNaive Bayes Classifiers7 min readUnsupervised LearningWhat is Unsupervised Learning5 min readK means Clustering â Introduction6 min readHierarchical Clustering in Machine Learning6 min readDBSCAN Clustering in ML - Density based clustering6 min readApriori Algorithm6 min readFrequent Pattern Growth Algorithm5 min readECLAT Algorithm - ML3 min readPrincipal Component Analysis(PCA)7 min readModel Evaluation and TuningEvaluation Metrics in Machine Learning9 min readRegularization in Machine Learning7 min readCross Validation in Machine Learning7 min readHyperparameter Tuning7 min readML | Underfitting and Overfitting5 min readBias and Variance in Machine Learning10 min readAdvanced TechniquesReinforcement Learning8 min readSemi-Supervised Learning in ML5 min readSelf-Supervised Learning (SSL)6 min readEnsemble Learning8 min readMachine Learning PracticeTop 50+ Machine Learning Interview Questions and Answers15+ min read100+ Machine Learning Projects with Source Code [2025]6 min read Like