Created
July 30, 2020 22:17
-
-
Save jlggross/4a7ec1046b3061898dca2c11c902f8c2 to your computer and use it in GitHub Desktop.
Creation of DataFrame after scrapping is complete
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
df = pd.DataFrame(columns=["Ação", "Taxa %"]) | |
for i, element in enumerate(elements): | |
if len(element.text) < 11: # If any li is empty | |
continue | |
newElement = {} | |
newElement["Ação"] = element.text.split("\n")[0] | |
newElement["Taxa %"] = element.text.split("\n")[1] | |
df = df.append(newElement, ignore_index=True) | |
df["Taxa %"] = df["Taxa %"].str.replace(",", ".") | |
df["Taxa %"] = df["Taxa %"].str.replace("%", "") | |
df["Taxa %"] = df["Taxa %"].astype('float') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment