Skip to content Skip to sidebar Skip to footer

Ignore/ Remove Some Lines When Reading Csv To Dataframe

i have a similar problem to this post, I'm gonna keep working with the data of this poste. Supposed that i have a text file which looks like this. How can i remove the rows highli

Solution 1:

To skip the first n rows, skiprows= parameter:

df = pd.read_csv(
    "movies.txt",
    sep=r"\s*\|\s*",
    comment="+",
    usecols=range(1, 13),
    skiprows=4,            # <-- add skiprows here
    engine="python",
)

Post a Comment for "Ignore/ Remove Some Lines When Reading Csv To Dataframe"