• How To Get The Dimension Of A DataFrame?

    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

    Read More

  • How To Display Only Row and Column Labels Of A DataFrame?

    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

    Read More

  • How To Select Only Values Of A DataFrame?

    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()

    Read More

  • How To Select Specific Data Type Columns?

    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

    Read More