In [92]:
import pandas as pd
df = pd.read_csv("W1.csv")
df
Out[92]:
In [93]:
df["Product"].str.upper()
Out[93]:
In [94]:
df["Company_Name"].str.upper()
Out[94]:
In [95]:
df["Product"].str.replace("tablet", "cellphone")
Out[95]:
In [96]:
df["Product"] = df["Product"].str.title()
In [97]:
df
Out[97]:
In [98]:
search = df["Company_Name"].dropna(how = "All").str.lower().str.contains("apple")
df[search]
Out[98]:
In [143]:
import pandas as pd
df = pd.read_csv("W1.csv")
#search = df["Product"].str.lower().str.startswith("ta", na=False)
#search
search = df["Company_Name"].str.lower().str.strip().str.startswith("a")
df[search]
Out[143]:
In [120]:
search = df["Company_Name"].str.lower().str.endswith("apple")
df[search]
Out[120]:
In [148]:
import pandas as pd
df = pd.read_csv("W1.csv")
df["Product"] = df["Product"].dropna(how="all")
df["Product"]
Out[148]:
In [149]:
df["Product"].replace("trackpad", "notracpad")
Out[149]:
In [159]:
import pandas as pd
df = pd.read_csv("W1.csv", index_col="Company_Name").dropna(how="all")
df["Product"] = df["Product"].astype("category")
df
df.index.str.strip().str.title()
df.index = df.index.str.strip().str.title()
df
Out[159]:
In [161]:
df.columns.str.upper()
Out[161]:
In [163]:
import pandas as pd
df = pd.read_csv("W1.csv")
df
Out[163]:
In [165]:
df["new_column"] = df["Product"].str.title()
df
Out[165]:
In [169]:
df["customerID"].nlargest(5)
Out[169]:
In [167]:
df["customerID"].nsmallest()
Out[167]:
In [ ]:
No comments:
Post a Comment