jovanisouza5 Posted May 5, 2022 Share Posted May 5, 2022 Olá, meus amigos! Como faço para transformar essa tabela abaixo em uma data.frame em Python? Empresa Latitude Longitude cluster 1 -24.93047 -49.99489 1 2 -24.95575 -49.99016 2 3 -24.92416 -50.00434 1 4 -24.95579 -50.00737 2 Link to comment Share on other sites More sharing options...
geovaniif Posted May 5, 2022 Share Posted May 5, 2022 Oi! bom, vc nao transforma uma tela numa dataframe explica melhor o que é essa tela, é array? é o que? é o resultado de um select num banco de dados? Link to comment Share on other sites More sharing options...
jovanisouza5 Posted May 5, 2022 Author Share Posted May 5, 2022 Obrigado por responder. Na verdade, eu gostaria de fazer um dataframe com essas informações acima. No R, eu faço da seguinte forma: df<-structure(list(Empresa = c(1,2,3,4), Latitude = c(-24.930473, -24.95575,-24.924161,-24.95579), Longitude = c(-49.994889, -49.990162,-50.004343, -50.007371), cluster = c(1,2,1,2)), class = "data.frame", row.names = c(NA, -4L)) Como ficaria em Python? Link to comment Share on other sites More sharing options...
geovaniif Posted May 10, 2022 Share Posted May 10, 2022 ata, entendi! cara, é MUITO parecido com R. Eu costumo criar um dicionario, que parece um json algo desse tipo: meu_dicionario = { "empresa" : [1,2,3,4], "latitude" : [v1, v2, v3, v4], "longitude" : [l1, l2, l3, l4], } #coloquei v1 v2 l1 l2 pq fiquei com preguiça de ver os valores meu_dataframe = pd.DataFrame(meu_dicionario) você também pode colocar direto na função DataFrame ao invez de criar variavel (da mesma forma que vc fez em R). Só separei pra ficar mais claro 1 Link to comment Share on other sites More sharing options...
jovanisouza5 Posted May 10, 2022 Author Share Posted May 10, 2022 Obrigado por responder! 😃 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now