0

I want to display data from .pbf (open street map, xml format) file. I have seen this answer, but I get an error:

NameError: name 'tag_genome' is not defined

Is sth wrong in his code?

EDITED QUESTION:

I edited his code a little, got a code:

df_osm = pd.DataFrame(handler.osm_data, columns=data_colnames)
tag_genome = pd.DataFrame(columns=data_colnames)

df_osm = tag_genome.sort_values(by=['type', 'id', 'ts'])

print(df_osm.head())

returns:

Empty DataFrame

Columns: [type, id, version, visible, ts, uid, user, chgset, ntags, tagkey, tagvalue]

Index: []

Why It says that dataframe is empty, when pbf file is existing..

Community
  • 1
  • 1
  • It doesn't work because the name `tag_genome` is not defined yet the code is trying to use it. – wwii Oct 19 '19 at 15:02
  • @wwii I see, but I do not understand what should be instead of tag_genome to show me table in his answer below –  Oct 19 '19 at 15:02
  • Provide a [mcve] (including data) with emphasis on minimal and someone might be able to help. – wwii Oct 19 '19 at 15:04
  • Python doesn't know what `tag_genome` is, because you didn't assign it. You didn't to something like `tag_genome = pd.DataFrame(array)`, or something. You need to assign a value to it before you use it. – Nicolas Gervais Oct 19 '19 at 15:04
  • @nicolasgervais I edited my question, please see –  Oct 19 '19 at 15:14
  • in `tag_genome = pd.DataFrame(columns=data_colnames)`, you just created an empty DataFrame with column names. The argument `columns` in `pd.DataFrame` only refers to the column _names_, it doesn't copy entire columns from another DataFrame. – Nicolas Gervais Oct 19 '19 at 15:16

0 Answers0