-

How To Get The Size Of A DataFrame?
How To Get The Size Of A DataFrame? Table Of Contents: Syntax To Get Size Of Data Frame. Examples Of Getting Size Of DataFrame. (1) Syntax: pandas.DataFrame.size Description: Return an int representing the number of elements in this object. Return the number of rows if Series. Otherwise, return the number of rows times the number of columns if DataFrame. (2) Examples Of Columns : Example-1 import pandas as pd student = {‘Name’:[‘Subrat’,’Abhispa’,’Arpita’,’Anuradha’,’Namita’], ‘Roll_No’:[100,101,102,103,104], ‘Subject’:[‘Math’,’English’,’Science’,’History’,’Commerce’], ‘Mark’:[95,88,76,73,93]} student_object = pd.DataFrame(student) student_object Output: student_object.size Output: 20 = 5 * 4 Example-1 s = pd.Series({‘a’: 1, ‘b’: 2, ‘c’: 3}) s Output: a
-

How To Get The Dimension Of A DataFrame?
How To Get The Dimension Of A DataFrame? Table Of Contents: Syntax To Print Dimension Of Data Frame. Examples Of Printing Dimension. (1) Syntax: property DataFrame.ndim Description: Return an int representing the number of axes / array dimensions. Return 1 if Series. Otherwise return 2 if DataFrame. (2) Examples Of Columns : Example-1 s = pd.Series({‘a’: 1, ‘b’: 2, ‘c’: 3}) s.ndim Output: 1 Example-2 df = pd.DataFrame({‘col1’: [1, 2], ‘col2’: [3, 4]}) df Output: df.ndim Output: 2
-

How To Display Only Row and Column Labels Of A DataFrame?
How To Display Only Row and Column Labels Of A DataFrame? Table Of Contents: Syntax To Display Only Row and Columns Of Data Frame. Examples Of Displaying Only Rows and Columns. (1) Syntax: pandas.DataFrame.axes Description: Return a list representing the axes of the DataFrame. It has the row axis labels and column axis labels as the only members. They are returned in that order. (2) Examples Of Displaying Rows and Columns : Example-1 import pandas as pd student = {‘Name’:[‘Subrat’,’Abhispa’,’Arpita’,’Anuradha’,’Namita’], ‘Roll_No’:[100,101,102,103,104], ‘Subject’:[‘Math’,’English’,’Science’,’History’,’Commerce’], ‘Mark’:[95,88,76,73,93]} student_object = pd.DataFrame(student) student_object Output: student_object.axes Output: [RangeIndex(start=0, stop=5, step=1), Index([‘Name’, ‘Roll_No’, ‘Subject’, ‘Mark’], dtype=’object’)] Example-2 import
-

How To Select Only Values Of A DataFrame?
How To Select Only Values Of A DataFrame? Table Of Contents: Syntax To Select Only Values Of A DataFrame. Examples Of Selecting Only Values. (1) Syntax: pandas.DataFrame.to_numpy() OR pandas.DataFrame.values Description: Only the values in the DataFrame will be returned, the axes labels will be removed. Returns: numpy.ndarray : The values of the DataFrame. (2) Examples Of Returning Only Values : Example-1 df = pd.DataFrame({‘age’: [ 3, 29], ‘height’: [94, 170], ‘weight’: [31, 115]}) df.to_numpy() Output: array([[ 3, 94, 31], [ 29, 170, 115]], dtype=int64) Example-2 df2 = pd.DataFrame([(‘parrot’, 24.0, ‘second’), (‘lion’, 80.5, 1), (‘monkey’, np.nan, None)], columns=(‘name’, ‘max_speed’, ‘rank’)) df2.to_numpy()
-

How To Select Specific Data Type Columns?
How To Select Specific Data Type Columns? Table Of Contents: Syntax To Select Specific DataType Columns. Examples Of Selecting Specific DataTypes. (1) Syntax: DataFrame.select_dtypes(include=None, exclude=None) Description: This method prints information about a DataFrame including the index dtype and columns, non-null values and memory usage. Parameters: include, exclude: scalar or list-like – A selection of dtypes or strings to be included/excluded. At least one of these parameters must be supplied. Returns: DataFrame – The subset of the frame including the dtypes in include and excluding the dtypes in exclude. Raises: ValueError- If both of include and exclude are empty If include and exclude have overlapping elements If any kind of string
-

How To Print Summary Of Your Data Frame?
How To Print Summary Of Your Data Frame? Table Of Contents: Syntax To Print Summary Of Data Frame. Examples Of Printing Summary. (1) Syntax: DataFrame.info(verbose=None, buf=None, max_cols=None, memory_usage=None, show_counts=None) Description: This method prints information about a DataFrame including the index dtype and columns, non-null values and memory usage.. Parameters: verbose: bool, optional – Whether to print the full summary. buf: writable buffer, defaults to sys.stdout – Where to send the output. By default, the output is printed to sys.stdout. memory_usage: bool, str, optional – Specifies whether total memory usage of the DataFrame elements (including the index) should be displayed. show_counts:
-

How To Get The DataTypes Of Columns Of A DataFrame?
How To Get The Data Types Of Columns Of A DataFrame? Table Of Contents: Syntax To Get The Data Types. Examples Of Getting Data Types. (1) Syntax pandas.DataFrame.dtypes pandas.DataFrame.dtypes.values Description: Return the dtypes of each columns of a DataFrame. (2) Examples Example-1 import pandas as pd student = {‘Name’:[‘Subrat’,’Abhispa’,’Arpita’,’Anuradha’,’Namita’], ‘Roll_No’:[100,101,102,103,104], ‘Subject’:[‘Math’,’English’,’Science’,’History’,’Commerce’], ‘Mark’:[95,88,76,73,93]} student_object = pd.DataFrame(student) student_object Output: student_object.dtypes Output: Name object Roll_No int64 Subject object Mark int64 dtype: object student_object.dtypes.values Output: array([dtype(‘O’), dtype(‘int64’), dtype(‘O’), dtype(‘int64’)], dtype=object) Example-2 import pandas as pd path = "E:BlogsPandasDocumentsMall_Customers.csv" customer_details = pd.read_csv(path) customer_details Output: customer_details.dtypes Output: CustomerID int64 Genre object Age int64 Annual_Income_(k$) int64 Spending_Score
-

How To Get The Columns Of A DataFrame?
How To Get The Columns Of A DataFrame? Table Of Contents: Syntax To Get The Column Names. Examples Of Fetching Column Names. (1) Syntax pandas.DataFrame.columns pandas.DataFrame.columns.values Description: It will fetch you the column names of the DataFrame. (2) Examples Of Columns : Example-1 import pandas as pd student = {‘Name’:[‘Subrat’,’Abhispa’,’Arpita’,’Anuradha’,’Namita’], ‘Roll_No’:[100,101,102,103,104], ‘Subject’:[‘Math’,’English’,’Science’,’History’,’Commerce’], ‘Mark’:[95,88,76,73,93]} student_object = pd.DataFrame(student) student_object Output: student_object.columns Output: Index([‘Name’, ‘Roll_No’, ‘Subject’, ‘Mark’], dtype=’object’) Note: Here you can see that, columns will give you, Index of Column names. Getting All The Column Values. student_object.column.values Output: array([‘Name’, ‘Roll_No’, ‘Subject’, ‘Mark’], dtype=object) Note: Here you can see that, columns.values will give
-

How To Get The Index Of A DataFrame?
How To Get The Index Of A DataFrame? Table Of Contents: Syntax Of Index Of DataFrame. Examples To Get The Index. (1) Syntax: pandas.DataFrame.index pandas.DataFrame.index.values Description: It will get you the index (row labels) of the DataFrame. (2) Examples Of Index : Example-1 import pandas as pd student = {‘Name’:[‘Subrat’,’Abhispa’,’Arpita’,’Anuradha’,’Namita’], ‘Roll_No’:[100,101,102,103,104], ‘Subject’:[‘Math’,’English’,’Science’,’History’,’Commerce’], ‘Mark’:[95,88,76,73,93]} student_object = pd.DataFrame(student) student_object Output: student_object.index Output: RangeIndex(start=0, stop=5, step=1) Note: Here you can see that, index starts from ‘0’ and stops at ‘5’, and the number of steps it increase is by ‘1’. Getting All The Index Values. student_object.index.values Output: array([0, 1, 2, 3, 4], dtype=int64)
-

How To Read CSV Files Using Pandas?
How To Read CSV Files Using Pandas? Table Of Contents: (1) How To Read CSV Files Using Pandas? (2) Examples Of Reading CSV Files. (1) How To Read CSV Files Using Pandas? Use the ‘read_csv( )’ method from pandas to read the CSV file. Read a comma-separated values (csv) file into DataFrame. Syntax: pandas.read_csv(filepath_or_buffer, *, sep=_NoDefault.no_default, delimiter=None, header=’infer’, names=_NoDefault.no_default, index_col=None, usecols=None, squeeze=None, prefix=_NoDefault.no_default, mangle_dupe_cols=True, dtype=None, engine=None, converters=None, true_values=None, false_values=None, skipinitialspace=False, skiprows=None, skipfooter=0, nrows=None, na_values=None, keep_default_na=True, na_filter=True, verbose=False, skip_blank_lines=True, parse_dates=None, infer_datetime_format=False, keep_date_col=False, date_parser=None, dayfirst=False, cache_dates=True, iterator=False, chunksize=None, compression=’infer’, thousands=None, decimal=’.’, lineterminator=None, quotechar=’"’, quoting=0, doublequote=True, escapechar=None, comment=None, encoding=None, encoding_errors=’strict’, dialect=None, error_bad_lines=None, warn_bad_lines=None,
