I have this database wich has too many rows for the project i need to do, so im trying to drop some with a few conditions, when i do this i have the error “not found in axis” wich everybody else got solutioned by adding the axis in the drop function, however not me, since i added that since the beggining and it still wont work
import networkx as nx
import pandas as pd
import matplotlib.pyplot as plt
#df = pd.read_csv("E:/Escritorio/tp mat 3/pbdb_data.csv") #direccion labo
df = pd.read_csv("D:/unsam/mat 3/TP 1/pbdb_data.csv") #direccion pc
df = df.drop(["orig_no","taxon_no","record_type","flags","difference","accepted_no","parent_no","immpar_no","immpar_name","container_no","reference_no","is_extant"], axis=1)
df = df.drop((df["taxon_name"] == pd.NA), axis=0)
df = df.drop((df["n_occs"]==1), axis=0)
print(df)
G = nx.from_pandas_edgelist(df[["parent_name", "taxon_name"]].drop_duplicates(), 'parent_name', 'taxon_name', create_using=nx.Graph())
nx.draw_networkx(G, with_labels=True)
nx.draw_networkx(G)
plt.draw()
the database looks like this:
taxon_rank taxon_name accepted_rank accepted_name parent_name n_occs
0 unranked clade Dinosauria unranked clade Dinosauria Dinosauriformes 1952
1 unranked clade Megalosauridae unranked clade Megalosauridae Dinosauria 2
2 unranked clade Ornithischia unranked clade Ornithischia Dinosauria 236
3 unranked clade Genasauria unranked clade Genasauria Ornithischia 208
4 unranked clade Cerapoda unranked clade Cerapoda Genasauria 173
.. ... ... ... ... ... ...
772 species Fusioolithus berthei species Fusioolithus berthei Fusioolithus 2
773 family Prismatoolithidae family Prismatoolithidae Dinosauria 1
774 family NaN NaN NaN NaN 4
775 genus Sauropodichnus unranked clade Dinosauria Dinosauria 4
776 species Sauropodichnus giganteus species Sauropodichnus giganteus Sauropodichnus 2
i tried using multiple formats in the declaration of the drop function but nothing works, even taking out the “axis=” doesnt affect it at all
Regtest is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.