def from_pandas(df, value='<STR_LIT:value>', x='<STR_LIT:x>', y='<STR_LIT:y>', cellx=None, celly=None, xmin=None, ymax=None,<EOL>geot=None, nodata_value=None, projection=None, datatype=None):
if not cellx:<EOL><INDENT>cellx = (df.sort_values(x)[x]-df.sort_values(x).shift(<NUM_LIT:1>)[x]).max()<EOL><DEDENT>if not celly:<EOL><INDENT>celly = (df.sort_values(y, ascending=False)[y]-df.sort_values(y, ascending=False).shift(<NUM_LIT:1>)[y]).drop_duplicates().replace(<NUM_LIT:0>).max()<EOL><DEDENT>if not xmin:<EOL><INDENT>xmin = df[x].min()<EOL><DEDENT>if not ymax:<EOL><INDENT>ymax = df[y].max()<EOL><DEDENT>row, col = map_pixel(df[x], df[y], cellx, celly, xmin, ymax)<EOL>dfout = pd.DataFrame(np.array([row, col, df[value]]).T, columns=['<STR_LIT>', '<STR_LIT>', '<STR_LIT:value>'])<EOL>dfout = dfout = dfout.set_index(["<STR_LIT>","<STR_LIT>"]).unstack().value.reindex(index=np.arange(<NUM_LIT:0>,np.max(row)+<NUM_LIT:1>)).T.reindex(index=np.arange(<NUM_LIT:0>,np.max(col)+<NUM_LIT:1>)).T<EOL>if nodata_value:<EOL><INDENT>dfout[np.isnan(dfout)] = nodata_value<EOL><DEDENT>if not nodata_value:<EOL><INDENT>nodata_value = np.nan<EOL><DEDENT>if not geot:<EOL><INDENT>geot = (xmin, cellx, <NUM_LIT:0>, ymax, <NUM_LIT:0>, celly)<EOL><DEDENT>return GeoRaster(dfout, geot, nodata_value=nodata_value, projection=projection, datatype=datatype)<EOL>
Creates a GeoRaster from a Pandas DataFrame. Useful to plot or export data to rasters.
Usage:
    raster = from_pandas(df, value='value', x='x', y='y', cellx= cellx, celly=celly,
                         xmin=xmin, ymax=ymax, geot=geot, nodata_value=ndv,
                         projection=projection, datatype=datatype)

Although it does not require all the inputs, it is highly recommended to include
the geographical information, so that the GeoRaster is properly constructed. As usual,
the information can be added afterwards directly to the GeoRaster.