You may want to temporarily create a suitable data frame to play with pandas.
#Import pandas
import pandas as pd
#Create a dataframe using range
df = pd.DataFrame({"col_name":range(4)})
print(df)
"""
col_name
0 0
1 1
2 2
3 3
"""
Try changing the name of the index and columns of the data frame you just created Further tweak the elements of the data frame
df.index = ["zero","one","two","three"]
df.columns = ["column"]
df.loc["one", "column"] = 7
print(df)
"""
column
zero 0
one 7
two 2
three 3
"""
#Make 5 or more elements of df NaN
df = df[df<5]
print(df)
"""
column
zero 0
one NaN
two 2
three 3
"""
#NaN yeah!Fill
df = df.fillna("yeah!")
print(df)
"""
column
zero 0
one yeah!
two 2
three 3
"""
Recommended Posts