Hot answers tagged

3

Using matplotlib, you could create a custom tick formatter to show the right ticks. The year and month can either be fetched from the dataframe via the index (df.iloc[value]['Month']) or just be calculated. Here is an example. You can also read the month name in the status bar when you hover over a position in the plot. The xticks (the positions where to ...


3

This commonly called a "word break" problem. There are a variety of approaches, the most common use dynamic programming or tries. You can recursively try candidates and keep the candidates if they can split the entire string. Here is a version (inspired by this answer): from functools import lru_cache @lru_cache(None) def wordbreak(string): if len(...


2

It depends on your knowledge of the problem. First, you should classify why is it missing?? Structurally missing data Structurally missing data is data that is missing for a logical reason. In other words, it is data that is missing because it should not exist.check this Structurally missing data is data that is missing for a logical reason. In other words,...


2

You have currently stored your numbers as strings causing matplotlib to treat your variable as categorical, hence the y-axis is not ordered as expected. Before plotting you should therefore first convert them to integers like this: x = [float(i.replace(",", ".")) for i in dev_x] You can then use plt.plot(x) once again to plot the values, this should give ...


2

First we use DataFrame.explode to unnest your lists to rows. Then we use DataFrame.pivot_table to pivot your dataframe from rows to column to get your desired result: dfn = df.assign(countries=df['countries'].str.split(',')).explode('countries') dfn['numbers'] = df.assign(numbers=df['numbers'].str.split(',')).explode('numbers')['numbers'] dfn = ( dfn....


2

There are several ways df[df['A']>=3] Maybe using query df.query('A >=3') Or using the .loc df.loc[df['A'] >= 3] This question is posted on several places.


1

You could always call on the pandas DataFrame's columns and work with that. values = df['price'] * df['quantity'] sum(values) if you want more information, I recommend https://stackoverflow.com/questions/14059094/i-want-to-multiply-two-columns-in-a-pandas-dataframe-and-add-the-result-into-a-n


1

There could be many reasons why you achieved 100% accuracy.One of them could be:Duplicates in your data which are repetitive in both train and test data.I would suggest you to try the following steps: 1.Check if there are any duplicates in the original data 2. Try a different Train-Test split like 80-20 3.Try k-Fold cross validation 4.Checkout for Precision ...


1

You are doing the split right, training in the train set and then testing in the test set. Seems weird yes. With out seeing your data, have you droped the target from the with you are trainning?? This could be a reason why you have a 100% accuracy. Other thing you could try is to plot the feature importance and check which features are contributing to the ...


1

I think you have misunderstood the koalas library. You can say its Pandas on Distributed System. You can use Koalas similar to pandas. There are few drawbacks with respect to APIs which is documented in their docs and few articles already written on medium. You can do your EDA and straight away use them in all the libraries you have mentioned. Recent ...


1

I would suggest you to scale your data using standard scaler and do it before you split it into X and Y here in your case. Why ? Please check this answer on stats sc. Also, keep the target variable (Front in your case) as it is. So, according to me, the right choice looks like this, however you can try and experiment with min max scaler too: from sklearn....


1

It depends on : Are the present data supposed to (or desmonstrated to) be informative for your problem ? If yes you might want to keep the feature. If no you might consider throwing them. Is the process for missingness informative or not ? Depending on that answer you might impute a value or not. You might add a proportion of missing value as a feature. ...


1

You can do a pandas.DataFrame.join if you know how this works. -- Edit: merge is apparently a better choice: See the example at the end. I think you need an outer join on Keyword. This should give a new DataFrame, that contains unique rows for the Keyword in both tables. Some entries may be NULL/None. This indicates that in the old or new table, the ...


1

In some cases, it may actually help getting better results (depending on the model type), but it is also likely that the improvement comes from the fact that the performance metric is computed differently. For instance, a skewed distribution will lead to high MSE values due to cases located on the other side of the distribution, while the MSE is limited if ...


Only top voted, non community-wiki answers of a minimum length are eligible