Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pandas change append -> concat (append in dfs removed in pandas>=2.) #1525

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 12 additions & 17 deletions examples/nlp/ipynb/masked_language_modeling.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
},
{
"cell_type": "code",
"execution_count": 0,
"execution_count": null,
"metadata": {
"colab_type": "code"
},
Expand Down Expand Up @@ -91,13 +91,12 @@
},
{
"cell_type": "code",
"execution_count": 0,
"execution_count": null,
"metadata": {
"colab_type": "code"
},
"outputs": [],
"source": [
"\n",
"@dataclass\n",
"class Config:\n",
" MAX_LEN = 256\n",
Expand Down Expand Up @@ -126,7 +125,7 @@
},
{
"cell_type": "code",
"execution_count": 0,
"execution_count": null,
"metadata": {
"colab_type": "code"
},
Expand All @@ -138,13 +137,12 @@
},
{
"cell_type": "code",
"execution_count": 0,
"execution_count": null,
"metadata": {
"colab_type": "code"
},
"outputs": [],
"source": [
"\n",
"def get_text_list_from_files(files):\n",
" text_list = []\n",
" for name in files:\n",
Expand All @@ -155,7 +153,6 @@
"\n",
"\n",
"def get_data_from_text_files(folder_name):\n",
"\n",
" pos_files = glob.glob(\"aclImdb/\" + folder_name + \"/pos/*.txt\")\n",
" pos_texts = get_text_list_from_files(pos_files)\n",
" neg_files = glob.glob(\"aclImdb/\" + folder_name + \"/neg/*.txt\")\n",
Expand All @@ -173,7 +170,8 @@
"train_df = get_data_from_text_files(\"train\")\n",
"test_df = get_data_from_text_files(\"test\")\n",
"\n",
"all_data = train_df.append(test_df)"
"# all_data = train_df.append(test_df)\n",
skon7 marked this conversation as resolved.
Show resolved Hide resolved
"all_data = pd.concat([train_df, test_df], ignore_index=True)"
]
},
{
Expand All @@ -199,13 +197,12 @@
},
{
"cell_type": "code",
"execution_count": 0,
"execution_count": null,
"metadata": {
"colab_type": "code"
},
"outputs": [],
"source": [
"\n",
"def custom_standardization(input_data):\n",
" lowercase = tf.strings.lower(input_data)\n",
" stripped_html = tf.strings.regex_replace(lowercase, \"<br />\", \" \")\n",
Expand Down Expand Up @@ -341,13 +338,12 @@
},
{
"cell_type": "code",
"execution_count": 0,
"execution_count": null,
"metadata": {
"colab_type": "code"
},
"outputs": [],
"source": [
"\n",
"def bert_module(query, key, value, i):\n",
" # Multi headed self-attention\n",
" attention_output = layers.MultiHeadAttention(\n",
Expand Down Expand Up @@ -520,7 +516,7 @@
},
{
"cell_type": "code",
"execution_count": 0,
"execution_count": null,
"metadata": {
"colab_type": "code"
},
Expand All @@ -545,7 +541,7 @@
},
{
"cell_type": "code",
"execution_count": 0,
"execution_count": null,
"metadata": {
"colab_type": "code"
},
Expand Down Expand Up @@ -617,13 +613,12 @@
},
{
"cell_type": "code",
"execution_count": 0,
"execution_count": null,
"metadata": {
"colab_type": "code"
},
"outputs": [],
"source": [
"\n",
"def get_end_to_end(model):\n",
" inputs_string = keras.Input(shape=(1,), dtype=\"string\")\n",
" indices = vectorize_layer(inputs_string)\n",
Expand Down Expand Up @@ -670,4 +665,4 @@
},
"nbformat": 4,
"nbformat_minor": 0
}
}
3 changes: 2 additions & 1 deletion examples/nlp/masked_language_modeling.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@ def get_data_from_text_files(folder_name):
train_df = get_data_from_text_files("train")
test_df = get_data_from_text_files("test")

all_data = train_df.append(test_df)
# all_data = train_df.append(test_df)
skon7 marked this conversation as resolved.
Show resolved Hide resolved
all_data = pd.concat([train_df, test_df], ignore_index=True)

"""
## Dataset preparation
Expand Down
3 changes: 2 additions & 1 deletion examples/nlp/md/masked_language_modeling.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,8 @@ def get_data_from_text_files(folder_name):
train_df = get_data_from_text_files("train")
test_df = get_data_from_text_files("test")

all_data = train_df.append(test_df)
#all_data = train_df.append(test_df)
skon7 marked this conversation as resolved.
Show resolved Hide resolved
all_data = pd.concat([train_df, test_df], ignore_index=True)
```
<div class="k-default-codeblock">
```
Expand Down