how to deal with Nan in Dataframe created with list comprehension (Python)

Asked

Viewed 127 times

-2

How can I take these NaN and leave the titles of the films, by any of the construction methods?

import pandas as pd
rating_data = pd.read_csv('ml-25m/ratings.csv')
movies_data = pd.read_csv('ml-25m/movies.csv')['title']
k = pd.DataFrame(movies_data.head(10), index =[ i for i in  range(1,11)], columns = ['título'])

s = pd.Series(data = k['título'], index = k.index)
print(k)
print(s)
  • A variable is called rating_data and the other movies_data?

1 answer

-1

I got it this way from Jupyter:

k = pd.Dataframe(movies_data.head(10).to_frame().title, index = [i for i in range(10)]) print(k) s = pd. Series(data = k.title, index = k.index) print(s)

can explain the syntax difference?

Browser other questions tagged

You are not signed in. Login or sign up in order to post.