This tutorial explains the difference between sep and delimiter in read_csv() and read_table() in Pandas. In short, `sep` and `delimiter` are the same in both read_csv()
and read_table()
functions in Pandas. You can use either one of them. In both function description, you can see the following statement.
delimiterstr, default None Alias for sep.
import pandas as pd
# use sep=" "
test_df = pd.read_table("test_df.txt", sep=" ")
#print out the dataframe
print(test_df)
Brand Location Year Random_number 0 Tesla CA 2019 88 1 Tesla CA 2018 33 2 Tesla NY 2020 44 3 Ford MA 2019 55
import pandas as pd
# use delimiter=" "
test_df = pd.read_table("test_df.txt", delimiter=" ")
#print out the dataframe
print(test_df)
Brand Location Year Random_number 0 Tesla CA 2019 88 1 Tesla CA 2018 33 2 Tesla NY 2020 44 3 Ford MA 2019 55
As you can see, both produced the same results.