Skip to content

Soumya-Chakraborty/Dataframes

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

   .______      ___      .__   __.  _______       ___           _______.     __  .__   __.      ______
   |   _  \    /   \     |  \ |  | |       \     /   \         /       |    |  | |  \ |  |     /      |
   |  |_)  |  /  ^  \    |   \|  | |  .--.  |   /  ^  \       |   (----`    |  | |   \|  |    |  ,----'
   |   ___/  /  /_\  \   |  . `  | |  |  |  |  /  /_\  \       \   \        |  | |  . `  |    |  |
   |  |     /  _____  \  |  |\   | |  '--'  | /  _____  \  .----)   |       |  | |  |\   |    |  `----.
   | _|    /__/     \__\ |__| \__| |_______/ /__/     \__\ |_______/        |__| |__| \__|     \______|

Implementing DataFrame Operations of Python (Pandas) in C Language

This C program demonstrates some basic operations on a DataFrame. The program creates a DataFrame structure, adds rows to it, and performs operations such as printing the DataFrame, calculating summary statistics, and performing aggregation.

Code Explanation

The code consists of the following components:

  1. Includes the necessary libraries for input/output and string handling.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
  1. Defines the Row structure to represent a single row of data in the DataFrame.
typedef struct {
    char name[20];
    int age;
    char city[20];
    char gender[10];
} Row;
  1. Defines the DataFrame structure to store rows and the number of rows.
typedef struct {
    Row* rows;
    int num_rows;
} DataFrame;
  1. Implements the createDataFrame function that creates a DataFrame with a given number of rows and initializes each row with default values.
DataFrame* createDataFrame(int num_rows) {
    // Implementation details
    return df;
}
  1. Implements the freeDataFrame function that frees the memory allocated for the DataFrame and its rows.
void freeDataFrame(DataFrame* df) {
    // Implementation details
}
  1. Implements the addRow function that adds a new row to the DataFrame.
void addRow(DataFrame* df, const char* name, int age, const char* city, const char* gender) {
    // Implementation details
}
  1. Implements the printDataFrame function that prints the contents of the DataFrame.
void printDataFrame(DataFrame* df) {
    // Implementation details
}
  1. Implements the calculateSummaryStatistics function that calculates and prints summary statistics of the DataFrame.
void calculateSummaryStatistics(DataFrame* df) {
    // Implementation details
}
  1. Implements the performAggregation function that performs aggregation on a specified column of the DataFrame.
void performAggregation(DataFrame* df, const char* column) {
    // Implementation details
}
  1. The main function demonstrates the usage of DataFrame operations. It creates a DataFrame, adds rows, and performs operations like printing the DataFrame, calculating summary statistics, and performing aggregation.
int main() {
    // Implementation details

    return 0;
}

Usage

  1. Compile the program using a C compiler.
gcc dataframe_operations.c -o dataframe_operations
  1. Run the executable.
./dataframe_operations

Output

The program generates the following output:

Name: John, Age: 25, City: New York, Gender: Male
Name: Alice, Age: 30, City: London, Gender: Female
Name: Bob, Age: 35, City: Paris, Gender: Male

Summary Statistics:
Total rows: 3
Minimum age: 25
Maximum age: 35
Average age: 30.00

Aggregation by gender:
Number of Males: 2
Number of Females: 1

Aggregation by city:
Number of Unique Cities: 3

Cleanup

The program frees the memory allocated for the DataFrame and its rows to avoid memory leaks.

License

This project is licensed under the MIT License.

Feel free to modify and use the code according to your needs.

Contributing

Contributions are welcome! Please open an issue or submit a pull request for any changes or improvements you would like to make.

Acknowledgements

This program was developed by Soumya Chakraborty as a demonstration of basic DataFrame operations in C.

About

This repository will provide few features of data frames

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages