Package: microframe
MicroFrameMicroFrame is a lightweight educational data manipulation library designed to provide a pandas-like interface for students learning to work with real-world data. It is optimized for toy datasets and aims to introduce users to data analysis concepts without the overhead of pandas.FeaturesEfficient CSV Reading: Quickly and easily read CSV files to create MicroFrame objects, optimized for educational purposes and smaller datasets.Data Type Handling: Advanced data type inference and explicit type setting offer both convenience and control over the structure of your data.Flexible MicroFrame Objects: Utilize MicroFrame objects that mimic pandas DataFrame for intuitive data manipulation and analysis.Clear Tabular Display: Use MicroFrame’s printing capabilities to generate well-formatted tabular representations of your data, making it easier to interpret and present.Robust Data Manipulation: Perform a variety of data manipulation tasks with methods similar to pandas, such as filtering, column dtype modification and summarizing data.Advanced Indexing: Access data efficiently with advanced indexing options, using theilocmethod similar to pandas iloc method.Data Conversion Tools: Seamlessly convert your MicroFrame objects to other formats, including NumPy arrays, with theto_numpymethod for further numerical computation.User-Friendly API: Experience a user-friendly API that mirrors pandas to facilitate the transition from educational projects to real-world data analysis.InstallationInstall MicroFrame using pip:pipinstallmicroframeQuick StartImport MicroFrame and load a dataset:importmicroframeasmf# Read a CSV file into a MicroFrame objectmframe=mf.read_csv("path_to_your_csv_file.csv")# Alternatively, create a MicroFrame object manuallydata=[[1,"a"],[2,"b"],[3,"c"]]columns=["num","char"]dtypes=["int32","U1"]mframe=mf.MicroFrame(data,columns,dtypes)ExamplesBasic UsageMicroFrame simplifies the process of data analysis. Here are some basic operations:Reading from a CSVimportmicroframeasmfmframe=mf.read_csv("path_to_your_csv_file.csv")Creating a MicroFrame Objectdata=[[1,"a"],[2,"b"],[3,"c"]]columns=["num","char"]dtypes=["int32","U1"]mframe=mf.MicroFrame(data,columns,dtypes)Data ManipulationMicroFrame provides several methods to manipulate your data:Renaming Columnsmframe.rename({"num":"number","char":"character"})Changing Data Typesmframe.change_dtypes({"number":"float64","character":"U10"})Accessing Column Data with Boolean Indexingdata=[[1,"a"],[2,"b"],[3,"c"]]columns=["num","char"]dtypes=["int32","U1"]mframe=mf.MicroFrame(data,columns,dtypes)first_col=mframe["num"]# Access just num columnAccessing Row Data withilocfirst_row=mframe.iloc[0]Advanced Indexing withilocTheilocindexer allows for integer-location based indexing:Accessing a Single Rowfirst_row=mframe.iloc[0]Accessing Multiple Rowsfirst_two_rows=mframe.iloc[:2]Accessing a Single Cellcell_value=mframe.iloc[2,1]Setting a Value in a Cellmframe.iloc[2,1]="Test"Slicing Rows and Columnssubset=mframe.iloc[:2,:2]Displaying DataSimilar to pandas, you can display parts of your dataset:Print the First Few Rowsmframe.head(2)Print the Last Few Rowsmframe.tail(2)Converting to NumPy ArrayFor times when you need to work with a NumPy array, MicroFrame provides theto_numpymethod:# Convert the MicroFrame to a 2D NumPy arraynumpy_array=mframe.to_numpy()This method will convert the structured data within the MicroFrame to a regular 2D NumPy array.Chainingilocwithto_numpyFor scenarios where you need to perform NumPy operations on a subset of your data, you can chain theilocindexer with theto_numpymethod:# Select the first two rows using iloc and convert them to a NumPy arraynumpy_subset=mframe.iloc[:,1:5].to_numpy()DocumentationFor full documentation, visit ourMicroFrame Documentation. Here, you will find detailed information on all the functionalities that MicroFrame offers.LicenseMicroFrame is released under theMIT License. Feel free to use it in your projects, and we'd love to hear about what you build!