-
Notifications
You must be signed in to change notification settings - Fork 0
/
pandas_utils.py
36 lines (27 loc) · 1.11 KB
/
pandas_utils.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import pandas as pd
def load_csv(file_path):
df = pd.read_csv(file_path)
return df
def describe_data(df):
return df.describe().to_html(classes='table table-striped table-bordered')
def head_data(df):
return df.head().to_html(classes='table table-striped table-bordered')
def no_columns(df):
return ','.join(df.columns)
def get_row(df,row_number):
try:
return df.iloc[[row_number]].to_html(classes='table table-striped table-bordered')
except IndexError:
return f"Invalid row Number Please choose a Row netween 0 t0 {len(df)-1}"
def help_command():
help_text = (
"<h4>Available Commands:</h4>"
"<ul>"
"<li><strong>describe</strong>: Get summary statistics of the dataset.</li>"
"<li><strong>head</strong>: View the top rows of the dataset.</li>"
"<li><strong>columns</strong>: List all column names in the dataset.</li>"
"<li><strong>row <number></strong>: View a specific row by number.</li>"
"<li><strong>help</strong>: Show this list of available commands.</li>"
"</ul>"
)
return help_text