0

I am wondering if there is an efficient way to read this census-related data (https://www2.census.gov/topics/genealogy/1990surnames/dist.all.last) into a pandas data table directly? So far the only way I can think of to parse the columns is to read each line individually, apply .split() and then use that list to create a data table. This seems like something pandas would have dealt with, but I don't know how.

RandoDoe
  • 15
  • 4

1 Answers1

0

For single space

import pandas as pd pd.read_csv('https://www2.census.gov/topics/genealogy/1990surnames/dist.all.last', sep=' ',header=None)

For multiple spaces (here)

pd.read_csv('https://www2.census.gov/topics/genealogy/1990surnames/dist.all.last', sep='\s+',header=None)

Also see Read Space-separated Data with Pandas

Community
  • 1
  • 1
Ajay Ohri
  • 3,382
  • 3
  • 30
  • 60