pandas fillna(0)

pandas fillna()

fillna()会填充nan数据,并返回填充后的结果。

import numpy as np 
import pandas as pd 
import matplotlib.pyplot as plt
import torch 
from torch import nn 
from torch.utils.data import Dataset,DataLoader,TensorDataset

dftrain_raw = pd.read_csv('./data/titanic/train.csv')
dftest_raw = pd.read_csv('./data/titanic/test.csv')
dftrain_raw.head(10)
dfdata = dftrain_raw
dfdata['Age'][:20]

pandas fillna(0)_第1张图片

fillna(0) 用0来填充缺失值

dfdata['Age'][:20].fillna(0)

pandas fillna(0)_第2张图片

你可能感兴趣的:(python问题,python)