Header Ads Widget

Responsive Advertisement

How del pop and drop function works in Dataframe:


Hello friends in this section we define how del pop and drop function delete elements from the data frame. just read this article and copy this code and execute in python then you will know how del pop and drop function works 

python


import pandas as pd


data = {

   'name': ['Xavier', 'Ann', 'Jana', 'Yi', 'Robin', 'Amal', 'Nori'],

   'city': ['Mexico City', 'Toronto', 'Prague', 'Shanghai',

          'Manchester', 'Cairo', 'Osaka'],

   'age': [41, 28, 33, 34, 38, 31, 37],

  'py-score': [88.0, 79.0, 81.0, 80.0, 68.0, 61.0, 84.0]}

row_labels = [101, 102, 103, 104, 105, 106, 107]

df = pd.DataFrame(data=data, index=row_labels)

print(df)


del df['py-score']

print(df)


df.pop('age')

print(df)


print(df.drop('name',axis=1))


print(df.drop(103,axis=0))


Post a Comment

0 Comments