By default, "na" is not considered NaN
by pandas.read_csv
.
You can add this as a NaN
string manually via the na_values
argument:
df = pd.read_csv('file.csv', na_values=['na'])
As per the docs :
na_values : scalar, str, list-like, or dict, default None
Additional strings to recognize as NA/NaN. If dict passed, specific per-column NA values. By default the following values are interpreted as NaN: '', '#N/A', '#N/AN/A', '#NA', '-1.#IND', '-1.#QNAN', '-NaN', '-nan', '1.#IND', '1.#QNAN', 'N/A', 'NA', 'NULL', 'NaN', 'n/a', 'nan', 'null'.
It looks like what your values are in this screenshot is not "NaN" or some real error, but a parsed string of the value "na".
In order to filter out the rows with this value in this column, you can use to simply refer to the df with a condition, instead of using dropna:
df = pd.read_csv(...)
filtered_df = df[df['Filmname'] != 'na']
The condition inside may be anything, see this guide for a start
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.