

Python - Pyproj Transform Returns inf for Blank Cell in CSV. How to ignore blank cell?
MyPythoncode converts latitude and longitude using pyproj. It reads this from an existing CSV file and writes a new CSV file with new code.
When it comes across a blank cell within the existing CSV file it writes in the cell of the new CSV file 'inf'
How can I stop it writing anything and leave the cell blank?
Current Python Code
from pyproj import Transformer
import pandas
pdf = pandas.read_csv("existing_file.csv", encoding='ANSI')
transformer = Transformer.from_crs("epsg:99999", "epsg:8888", always_xy=True)
xx, yy = transformer.transform(pdf["longitude"].values, pdf["latitude"].values)
pdf = pdf.assign(longitude=xx, latitude=yy)
pdf.to_csv("new_file.csv")
Python


This is beyond the scope of the tutorials. Please refer to Pandas documentation
Login to add comment