Posts

Showing posts with the label Coding

Flutter Framework - Refractored Camera Widget

Image
For those who are new to the Flutter Framework  and looking to learn and use the camera, the  Take a picture using the camera  cookbook is a great place to start. I followed the instructions and it worked fine. The next step for me was to refactor the code so that the camera widget was in its own dart file. How to Avoid Getting "LateInitializationError: Field 'controller' has not been initialized" Error The key is to create async function to wait for the camera to be fully initialized and use it with the already written FutureBuilder . Future < void > initCamera () async { final cameras = await availableCameras (); // Get a specific camera from the list of available cameras. final firstCamera = cameras . first ; // To display the current output from the Camera, // create a CameraController. _controller = CameraController ( // Get a specific camera from the list of available cameras. firstCamera , // Define the r...

Python Pandas: Replacement method for convert_objects()

Image
The  DataFrames.convert_objects()  in Pandas is a very useful function to try to infer better data types for you imported data. For example if you have just imported hockey player stats and the data looks like: df.dtypes Out[1]:  PLAYER    object TEAM      object GP        object G         object A         object PTS       object +/-       object dtype: object Using convert_objects: df.convert_objects(convert_numeric=True).dtypes  __main__:1: FutureWarning: convert_objects is deprecated.  Use the data-type specific converters pd.to_datetime, pd.to_timedelta and pd.to_numeric. Out[2]:  PLAYER     object TEAM       object GP          int64 G           int64 A           int64 PTS     ...