-1

I have a dataframe with the top 10 Google search results for certain requests. I display this data on a graph. According to the axis X, I have domains, according to the axcis Y, their position. The problem is that several pages of the same domain can be simultaneously in the top 10, which is why a duplicate appears on the axis X, which is not displayed on the chart.

Question: is it possible to somehow bypass this and still display all domains, even if they are duplicated?

Example of dataframe: enter image description here

What does the graph look like: enter image description here

Code of chart:

serp_csv2 = pd.read_csv('all.csv')
rent_serp = serp_csv2[serp_csv2['searchTerms'].str.contains("аренда", regex=True, case=False)]
rent_serp['bubble_size'] = 35
rent_serp.set_index("queryTime", inplace=True)

fig = px.scatter(rent_serp, x="displayLink", y="rank", animation_frame=rent_serp.index, animation_group="displayLink",
            color="displayLink", hover_name="link", hover_data=["title"],
           log_y=False, 
           height=710, width=900, range_x=[-1,11], range_y=[1,11],  size="bubble_size", text="displayLink", template="plotly_dark", title="Heartbeat of SERP for 'аренда квартир киев'", labels={"rank":"Rankings","displayLink":"Domain Names"})
fig.layout.updatemenus[0].buttons[0].args[1]["frame"]["duration"] = 450
fig.layout.updatemenus[0].buttons[0].args[1]["transition"]["duration"] = 1500
fig.update_xaxes(
        title_font = {"size": 20},
        title_standoff = 45)
fig.update_yaxes(
        title_font = {"size": 20},
        title_standoff = 45)
fig.show(renderer='notebook')
andreykirv
  • 21
  • 2
  • Please do not provide data samples as screenshots. Not very many would be interested in typing in data manually in order to help you. You can easily share a sample of your data [like this](https://stackoverflow.com/questions/63163251/pandas-how-to-easily-share-a-sample-dataframe-using-df-to-dict/63163254#63163254) – vestland Jun 01 '21 at 06:33

1 Answers1

0

you could add the names to a list then just remove the duplicate for example


my_list = ['a','x','a','y','a','b','b','c']

my_final_list = OrderedDict.fromkeys(my_list)

print(list(my_final_list))

#OUTPUT[['a', 'x', 'y', 'b', 'c']]