The tags are found and now we can create a for loop .
Result:
Data frame
STEP 9. CLEANING THE DATA FRAME
Next, once the data frame has been successfully hong kong telegram database created, we can delete and clean up unnecessary rows. In our case, we will delete the index 0-6, 222-228, then reset the index to its original state and delete the "#" column.
# Drop and clearing unnecessary rows
mydata.drop(mydata.index[0:7], inplace=True)
mydata.drop(mydata.index[222:229], inplace=True)
mydata.reset_index(inplace=True, drop=True)
# Drop “#” column
mydata.drop(‘#’, inplace=True, axis=1)
Result:
Final data frame
Once the data frame is ready, we can export the data to a CSV file.
# Export to csv
mydata.to_csv(‘covid_data.csv’, index=False)
Create a for loop to fill mydata
-
- Posts: 453
- Joined: Tue Dec 24, 2024 6:59 am