huggingface112 commited on
Commit
6eb9bc1
1 Parent(s): 3e323f0

formatting

Browse files
Files changed (1) hide show
  1. utils.py +5 -4
utils.py CHANGED
@@ -7,6 +7,7 @@ from sqlalchemy import create_engine
7
 
8
  db_url = 'sqlite:///instance/local.db'
9
 
 
10
  def time_in_beijing(strip_time_zone=True):
11
  '''
12
  return current time in Beijing as datetime object
@@ -17,14 +18,15 @@ def time_in_beijing(strip_time_zone=True):
17
  dt = dt.replace(tzinfo=None)
18
  return dt
19
 
 
20
  def add_details_to_stock_df(stock_df):
21
  '''return df adding sector, aggregate sector, display_name, name to it
22
-
23
  Parameters
24
  ----------
25
  stock_df: pd.DataFrame
26
  the dataframe contain ticker columns
27
-
28
  Returns
29
  -------
30
  merged_df: pd.DataFrame
@@ -42,6 +44,7 @@ def add_details_to_stock_df(stock_df):
42
  merged_df['aggregate_sector'].fillna('其他', inplace=True)
43
  return merged_df
44
 
 
45
  def convert_string_to_datetime(date_string, time_zone="Asia/Shanghai"):
46
  '''
47
  Convert a string to a datetime object with the timezone by default,
@@ -137,5 +140,3 @@ def create_share_changes_report(df):
137
  markdown += '{} | {} | {}\n'.format(row['ticker'],
138
  row['display_name'], share_changes_str)
139
  return markdown
140
-
141
-
 
7
 
8
  db_url = 'sqlite:///instance/local.db'
9
 
10
+
11
  def time_in_beijing(strip_time_zone=True):
12
  '''
13
  return current time in Beijing as datetime object
 
18
  dt = dt.replace(tzinfo=None)
19
  return dt
20
 
21
+
22
  def add_details_to_stock_df(stock_df):
23
  '''return df adding sector, aggregate sector, display_name, name to it
24
+
25
  Parameters
26
  ----------
27
  stock_df: pd.DataFrame
28
  the dataframe contain ticker columns
29
+
30
  Returns
31
  -------
32
  merged_df: pd.DataFrame
 
44
  merged_df['aggregate_sector'].fillna('其他', inplace=True)
45
  return merged_df
46
 
47
+
48
  def convert_string_to_datetime(date_string, time_zone="Asia/Shanghai"):
49
  '''
50
  Convert a string to a datetime object with the timezone by default,
 
140
  markdown += '{} | {} | {}\n'.format(row['ticker'],
141
  row['display_name'], share_changes_str)
142
  return markdown