pip3 install pandas
Create a table with data:
In [0]:
try:
import numpy as np
except:
!pip3 install numpy
import numpy as np
try:
import pandas as pd
except:
!pip3 install pandas
import pandas as pd
In [0]:
df = pd.DataFrame({'int_col' : [1, 2, 6, 8, -1],
'float_col' : [0.1, 0.2, 0.2, 10.1, None],
'str_col' : ['a', 'b', None, 'c', 'a']})
print(df)
df
Out[0]:
Arithmetic average of a column:
In [0]:
df2 = df.copy()
mean = df2['float_col'].mean()
mean
Out[0]:
Replace undefined elements:
In [0]:
df3 = df['float_col'].fillna(mean)
df3
Out[0]:
Create a table by means of columns:
In [0]:
df4 = pd.concat([df3, df['int_col'], df['str_col']], axis=1)
df4
Out[0]: