Update README.md
Browse files
README.md
CHANGED
@@ -49,4 +49,49 @@ locations=[
|
|
49 |
119.5213933664,
|
50 |
7.2037547089,
|
51 |
]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
52 |
```
|
|
|
49 |
119.5213933664,
|
50 |
7.2037547089,
|
51 |
]
|
52 |
+
```
|
53 |
+
|
54 |
+
### Some rows are messed up so you should remove the rows with empty values first:
|
55 |
+
```
|
56 |
+
import pandas as pd
|
57 |
+
import numpy as np
|
58 |
+
|
59 |
+
# Define the data types for specific columns
|
60 |
+
dtype_spec = {
|
61 |
+
'tweet_created_at': str,
|
62 |
+
'tweet_timestamp_ms': str,
|
63 |
+
'tweet_id_str': str,
|
64 |
+
'tweet_lang': str,
|
65 |
+
'tweet_text': str,
|
66 |
+
'tweet_possibly_sensitive': str,
|
67 |
+
'user_id_str': str,
|
68 |
+
'user_screen_name': str,
|
69 |
+
'user_followers_count': str
|
70 |
+
}
|
71 |
+
|
72 |
+
# Load the CSV file with specified data types
|
73 |
+
df = pd.read_csv('extracted_data0.csv', dtype=dtype_spec)
|
74 |
+
print(df.dtypes)
|
75 |
+
|
76 |
+
# Replace empty strings with NaN
|
77 |
+
df.replace('', np.nan, inplace=True)
|
78 |
+
# Drop rows where any column is empty (NaN)
|
79 |
+
df = df.dropna()
|
80 |
+
|
81 |
+
new_dtypes = {
|
82 |
+
'tweet_created_at': str,
|
83 |
+
'tweet_timestamp_ms': int,
|
84 |
+
'tweet_id_str': str,
|
85 |
+
'tweet_lang': str,
|
86 |
+
'tweet_text': str,
|
87 |
+
'tweet_possibly_sensitive': bool,
|
88 |
+
'user_id_str': str,
|
89 |
+
'user_screen_name': str,
|
90 |
+
'user_followers_count': int
|
91 |
+
}
|
92 |
+
|
93 |
+
df = df.astype(new_dtypes)
|
94 |
+
|
95 |
+
# Display the data types to verify
|
96 |
+
print(df.dtypes)
|
97 |
```
|