<jupyter_start><jupyter_text>Unpivot GIS DataGIS analysis and visualizaiton typically needs data with 1 value per row. If your data is structured in columns, you need to 'unpivot' it to convert it to 1 value per row. Note that this will result in duplicate features, but they can be handled well in GIS.Example Excel workbook is structured like this| id | species1 | species2 | .. | value 1 | value 2 | ... || -- | -------- | -------- | -- | ------- | ------- | --- || 1  | s1       | s2       | .. | 10     | 20      | ... |This script will convert it to a table like follows| id | species | value || -- | ------- | ----- || 1  | s1       | 10   || 1  | s2       | 20   |<jupyter_code>import pandas as pd
input = 'original.xlsx'
df = pd.read_excel(input)
df1 = pd.melt(df, id_vars=['id', 'species1'], value_vars=['value1']).rename(columns = {'value1':'value'})
df1 = pd.melt(df, id_vars=['id', 'species2'], value_vars=['value2']).rename(columns = {'value2':'value'})
merged = pd.concat([df1, df2])
# Drop rows which have null values 
merged = merged.dropna(axis=0, how='any')
output = 'unpivoted.xlsx'
merged.to_excel(output, index=False)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.18135158254918735, 'fraction_numerical': 0.02737382378100941, 'mean_word_length': 2.993174061433447, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '419879', 'license': 'Apache-2.0', 'n_tokens_mistral': 413, 'n_tokens_neox': 382, 'n_words': 123, 'path': 'misc/unpivot.ipynb', 'repo_name': 'craigdsouza/projects', 'size': '1169'}