Looking for a fast way to get a row in a pandas dataframe into a ordered dict with out using list. List are fine but with large data sets will take to long. I am using fiona GIS reader and the rows are ordereddicts with the schema giving the data type. I use pandas to join data. I many cases the rows will have different types so I was thinking turning into a numpy array with type string might do the trick.
相关问题
- how to define constructor for Python's new Nam
- streaming md5sum of contents of a large remote tar
- How to get the background from multiple images by
- Evil ctypes hack in python
- Correctly parse PDF paragraphs with Python
Unfortunately you can't just do an apply (since it fits it back to a DataFrame):
But you can use a list comprehension with iterrows:
If it was possible to use a generator, rather than a list, to whatever you were working with this will usually be more efficient:
This is implemented in
pandas 0.21.0+
in functionto_dict
with parameterinto
: