Spaces:
Sleeping
Sleeping
Commit
·
4b97f31
1
Parent(s):
0661099
DB storage debug 4
Browse files- Functions/caption_editor_functions.py +17 -0
- Functions/test.py +17 -0
Functions/caption_editor_functions.py
CHANGED
|
@@ -14,12 +14,22 @@ def get_captions_by_video_id(video_id):
|
|
| 14 |
|
| 15 |
|
| 16 |
def save_dataframe(df, df_full, video_id, user):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
if len(df.index) > len(df_full.index):
|
| 18 |
new_rows = len(df_full.index) - len(df.index)
|
| 19 |
empty_data = {col: [None for _ in range(new_rows)] for col in df_full.columns}
|
| 20 |
empty_df = pd.DataFrame(empty_data)
|
| 21 |
|
| 22 |
df_full = pd.concat([df_full, empty_df], ignore_index=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
try:
|
| 24 |
df_full["user_id"].loc[
|
| 25 |
df_full["start_time"] != df["Start"] or
|
|
@@ -30,7 +40,14 @@ def save_dataframe(df, df_full, video_id, user):
|
|
| 30 |
df_full["text"] = df["Text"]
|
| 31 |
df_full["end_time"] = df["End"].apply(lambda x: float(x))
|
| 32 |
|
|
|
|
|
|
|
|
|
|
| 33 |
df_json = df_full.to_json(orient="index")
|
|
|
|
|
|
|
|
|
|
|
|
|
| 34 |
default_app.database().child("Captions").child(video_id).set(df_json)
|
| 35 |
|
| 36 |
return "Save successful!"
|
|
|
|
| 14 |
|
| 15 |
|
| 16 |
def save_dataframe(df, df_full, video_id, user):
|
| 17 |
+
|
| 18 |
+
print("df:")
|
| 19 |
+
print(df)
|
| 20 |
+
print("df full:")
|
| 21 |
+
print(df_full)
|
| 22 |
+
|
| 23 |
if len(df.index) > len(df_full.index):
|
| 24 |
new_rows = len(df_full.index) - len(df.index)
|
| 25 |
empty_data = {col: [None for _ in range(new_rows)] for col in df_full.columns}
|
| 26 |
empty_df = pd.DataFrame(empty_data)
|
| 27 |
|
| 28 |
df_full = pd.concat([df_full, empty_df], ignore_index=True)
|
| 29 |
+
|
| 30 |
+
print("extra rows df full:")
|
| 31 |
+
print(df_full)
|
| 32 |
+
|
| 33 |
try:
|
| 34 |
df_full["user_id"].loc[
|
| 35 |
df_full["start_time"] != df["Start"] or
|
|
|
|
| 40 |
df_full["text"] = df["Text"]
|
| 41 |
df_full["end_time"] = df["End"].apply(lambda x: float(x))
|
| 42 |
|
| 43 |
+
print("df full:")
|
| 44 |
+
print(df_full)
|
| 45 |
+
|
| 46 |
df_json = df_full.to_json(orient="index")
|
| 47 |
+
|
| 48 |
+
print("json")
|
| 49 |
+
print(df_json)
|
| 50 |
+
|
| 51 |
default_app.database().child("Captions").child(video_id).set(df_json)
|
| 52 |
|
| 53 |
return "Save successful!"
|
Functions/test.py
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import pandas as pd
|
| 2 |
+
|
| 3 |
+
df = pd.DataFrame()
|
| 4 |
+
df2 = pd.DataFrame()
|
| 5 |
+
|
| 6 |
+
df['Name'] = ['Anna', 'Pete', 'Tommy']
|
| 7 |
+
df['Scores'] = [97, 600, 200]
|
| 8 |
+
|
| 9 |
+
df2['Name'] = ['Anna', 'Pete', "None"]
|
| 10 |
+
df2['Scores'] = [97, 601, None]
|
| 11 |
+
|
| 12 |
+
# print(df)
|
| 13 |
+
# print(df2)
|
| 14 |
+
# df["Name"].loc[
|
| 15 |
+
# df2["Scores"] != df["Scores"]
|
| 16 |
+
# ] = "Test"
|
| 17 |
+
print(df2["Scores"] != df["Scores"])
|